标签:
应该是三周的时间,感觉要是每天就只做这个的话一周时间也是可以的,但毕竟我们是大学教育。
我们小组终于齐心协力完成了这第一个人机界面设计,其实还是挺开心的,第一次合作,我第一次当名义上的组长。当然还没有结束,这周五还要在课堂上介绍,我也是蛮期待。
话不多说,今晚就先来看我负责的模块——管理员界面。
这个界面本来是另一个组员写的,结果到头来还是我完成了。但我们俩人之前的讨论和分析也是很有用的。
首先的主界面以及代码:
package 剧院管理界面; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.ImageObserver; import java.util.Vector; import javax.swing.*; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; public class mainUI extends JPanel{ GridBagLayout layout=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); JMenuBar menubar1 = new JMenuBar(); JMenuItem menu1=new JMenuItem("影片查询"); JMenuItem menu2=new JMenuItem("添加影片"); JMenuItem menu3=new JMenuItem("放映厅"); JMenuItem menu4=new JMenuItem("数据统计"); JFrame jf=new JFrame("剧院内部管理系统"); static JPanel jp=new JPanel(new GridLayout(1,1)); Toolkit kit=Toolkit.getDefaultToolkit(); Dimension screeSize=kit.getScreenSize(); static JScrollPane js; public mainUI(){ menu1.setFont(new Font("宋体", Font.BOLD, 26)); menu2.setFont(new Font("宋体", Font.BOLD, 26)); menu3.setFont(new Font("宋体", Font.BOLD, 26)); menu4.setFont(new Font("宋体", Font.BOLD, 26)); menubar1.add(menu1); menubar1.add(menu2); menubar1.add(menu3); menubar1.add(menu4); jf.setJMenuBar(menubar1); jf.add(jp); jf.setSize(screeSize.width-600, screeSize.height-400); jf.setVisible(true); jf.setLocationRelativeTo(null); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); menu1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { jp.removeAll(); jp.updateUI(); js=new JScrollPane(new searchMovie()); jp.add(js); } }); menu2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { jp.removeAll(); jp.updateUI(); js=new JScrollPane(new addMovie()); jp.add(js); } }); menu3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { jp.removeAll(); jp.updateUI(); JTabbedPane tp=new JTabbedPane(); showRoomInfo con=new showRoomInfo(); showRoomInfo1 con1=new showRoomInfo1(); showRoomInfo2 con2=new showRoomInfo2(); JPanel f3=new JPanel(); JPanel f4=new JPanel(); tp.setTabPlacement(JTabbedPane.LEFT); tp.addTab("一号厅",con); tp.addTab("二号厅",con1); tp.addTab("三号厅",con2); tp.addTab("四号厅", f3); tp.addTab("五号厅", f4); jp.add(tp,BorderLayout.CENTER); } }); menu4.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { jp.removeAll(); jp.updateUI(); js=new JScrollPane(new dataCount()); jp.add(js); } }); Vector bt = new Vector(); bt.add("电影名"); bt.add("放映场次"); bt.add("放映厅"); bt.add("票价"); bt.add("影片状态"); Vector data1 = new Vector(); data1.add("疯狂动物城"); data1.add("7:30,11:20,14:00,18:45"); data1.add("一号厅"); data1.add("30"); data1.add("正在热映"); Vector data2 = new Vector(); data2.add("叶问3"); data2.add("6:30,12:20,14:30"); data2.add("二号厅"); data2.add("25"); data2.add("即将下架"); Vector data3 = new Vector(); data3.add("荒野猎人"); data3.add("8:00,10:30,13:00,17:25"); data3.add("一号厅"); data3.add("30"); data3.add("正在热映"); Vector data4 = new Vector(); data4.add("美人鱼"); data4.add("9:20,10:30,11:20,12:45,16:00,20:45"); data4.add("三号厅"); data4.add("30"); data4.add("正在热映"); Vector data5 = new Vector(); data5.add("澳门风云3"); data5.add("9:00,15:20"); data5.add("四号厅"); data5.add("25"); data5.add("即将下架"); Vector data6 = new Vector(); data6.add("蝙蝠侠大战超人:正义黎明"); data6.add("8:20,13:20,15:10,17:25"); data6.add("一号厅"); data6.add("30"); data6.add("马上公映"); Vector data7 = new Vector(); data7.add("神战:权力之眼"); data7.add("7:30,18:45"); data7.add("二号厅"); data7.add("30"); data7.add("即将下架"); Vector data8 = new Vector(); data8.add("女汉子真爱公式"); data8.add("9:30,13:00,16:45"); data8.add("三号厅"); data8.add("30"); data8.add("正在热映"); Vector data9 = new Vector(); data9.add("功夫熊猫3"); data9.add("7:40,10:20,11:20,14:00,18:45"); data9.add("一号厅"); data9.add("30"); data9.add("正在热映"); Vector data10 = new Vector(); data10.add("我的特工爷爷"); data10.add("9:20,12:30,16:00,18:55"); data10.add("三号厅"); data10.add("30"); data10.add("马上公映"); Vector data11 = new Vector(); data11.add("火影忍者:博人传"); data11.add("7:50,12:20,15:00,20:45"); data11.add("二号厅"); data11.add("30"); data11.add("正在热映"); Vector data12 = new Vector(); data12.add("老炮儿"); data12.add("9:10,12:40,15:10,21:45"); data12.add("一号厅"); data12.add("30"); data12.add("即将下架"); Vector datas = new Vector(); datas.add(data2); datas.add(data5); datas.add(data7); datas.add(data12); datas.add(data1); datas.add(data3); datas.add(data4); datas.add(data8); datas.add(data9); datas.add(data11); datas.add(data6); datas.add(data10); DefaultTableModel dd=new DefaultTableModel(datas, bt); JTable tab = new JTable(); tab.setModel(dd); tab.setRowHeight(30); tab.setFont(new Font("Menu.font", Font.PLAIN, 25)); js=new JScrollPane(tab); jp.add(js,BorderLayout.SOUTH); /* JButton d=new JButton("删除"); d.setFont(new Font("宋体", Font.BOLD, 30)); jp.add(d, BorderLayout.CENTER); d.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = tab.getSelectedColumn(); if(row == -1){ JOptionPane.showMessageDialog(mainUI.this,"请选择要删除的行!"); }else{ dd.removeRow(row-1); } } });*/ } }个人认为亮点在插入了表格,但是不足也在于这个界面的功能还是没有完整实现,对表格的修改和删除还没有添加进去。
当然,创建表格的方法也是很不好,不是很方便,其实是有更好的方法。
下面是各个功能及其代码
package 剧院管理界面; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.ImageObserver; import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; public class searchMovie extends JPanel{ GridBagLayout layout=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); JLabel jl1=new JLabel("输入电影名称:"); JTextField jt1=new JTextField(15); JButton button1=new JButton("查询"); JButton button2=new JButton("返回"); public searchMovie(){ setLayout(layout); gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jl1,gbc); jl1.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jt1,gbc); gbc.gridx=0; gbc.gridy=6; gbc.gridwidth=1; gbc.gridheight=50; button1.setFont(new Font("宋体", Font.BOLD, 20)); add(button1,gbc); gbc.gridx=1; gbc.gridy=6; gbc.gridwidth=1; gbc.gridheight=50; button2.setFont(new Font("宋体", Font.BOLD, 20)); add(button2,gbc); JFrame search=new JFrame(); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search.setVisible(true); } }); search.setLayout(new GridLayout(4,2,5,5)); JLabel j1=new JLabel("导演:"); j1.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j1); JLabel j2=new JLabel("Tom"); j2.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j2); JLabel j3=new JLabel("主演:"); j3.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j3); JLabel j4=new JLabel("朱迪,尼克"); j4.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j4); JLabel j5=new JLabel("影片内容:"); j5.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j5); JLabel t=new JLabel("讲述了动物城里朱迪为了梦想和尼克邂逅的故事"); t.setFont(new Font("宋体", Font.BOLD, 30)); t.setToolTipText("为了证明自己,她决心侦破一桩神秘案件;追寻真相的路上她被迫与口若悬河、谎技高超的狐尼克联手,却发现这桩案件背后隐藏着一个意欲颠覆动物城的巨大阴谋!"); search.add(t); JLabel j6=new JLabel("影片状态:"); j6.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j6); JLabel j7=new JLabel("正在热映"); j7.setFont(new Font("宋体", Font.BOLD, 30)); search.add(j7); search.setSize(700, 500); search.setLocationRelativeTo(null); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainUI.jp.removeAll(); mainUI.jp.updateUI(); mainUI.jp.setVisible(true); Vector bt = new Vector(); bt.add("电影名"); bt.add("放映场次"); bt.add("放映厅"); bt.add("票价"); bt.add("影片状态"); Vector data1 = new Vector(); data1.add("疯狂动物城"); data1.add("7:30,11:20,14:00,18:45"); data1.add("一号厅"); data1.add("30"); data1.add("正在热映"); Vector data2 = new Vector(); data2.add("叶问3"); data2.add("6:30,12:20,14:30"); data2.add("二号厅"); data2.add("25"); data2.add("即将下架"); Vector data3 = new Vector(); data3.add("荒野猎人"); data3.add("8:00,10:30,13:00,17:25"); data3.add("一号厅"); data3.add("30"); data3.add("正在热映"); Vector data4 = new Vector(); data4.add("美人鱼"); data4.add("9:20,10:30,11:20,12:45,16:00,20:45"); data4.add("三号厅"); data4.add("30"); data4.add("正在热映"); Vector data5 = new Vector(); data5.add("澳门风云3"); data5.add("9:00,15:20"); data5.add("四号厅"); data5.add("25"); data5.add("即将下架"); Vector data6 = new Vector(); data6.add("蝙蝠侠大战超人:正义黎明"); data6.add("8:20,13:20,15:10,17:25"); data6.add("一号厅"); data6.add("30"); data6.add("马上公映"); Vector data7 = new Vector(); data7.add("神战:权力之眼"); data7.add("7:30,18:45"); data7.add("二号厅"); data7.add("30"); data7.add("即将下架"); Vector data8 = new Vector(); data8.add("女汉子真爱公式"); data8.add("9:30,13:00,16:45"); data8.add("三号厅"); data8.add("30"); data8.add("正在热映"); Vector data9 = new Vector(); data9.add("功夫熊猫3"); data9.add("7:40,10:20,11:20,14:00,18:45"); data9.add("一号厅"); data9.add("30"); data9.add("正在热映"); Vector data10 = new Vector(); data10.add("我的特工爷爷"); data10.add("9:20,12:30,16:00,18:55"); data10.add("三号厅"); data10.add("30"); data10.add("马上公映"); Vector data11 = new Vector(); data11.add("火影忍者:博人传"); data11.add("7:50,12:20,15:00,20:45"); data11.add("二号厅"); data11.add("30"); data11.add("正在热映"); Vector data12 = new Vector(); data12.add("老炮儿"); data12.add("9:10,12:40,15:10,21:45"); data12.add("一号厅"); data12.add("30"); data12.add("即将下架"); Vector datas = new Vector(); datas.add(data2); datas.add(data5); datas.add(data7); datas.add(data12); datas.add(data1); datas.add(data3); datas.add(data4); datas.add(data8); datas.add(data9); datas.add(data11); datas.add(data6); datas.add(data10); DefaultTableModel dd=new DefaultTableModel(datas, bt); JTable tab = new JTable(); tab.setModel(dd); tab.setFont(new Font("Menu.font", Font.PLAIN, 25)); tab.setRowHeight(30); mainUI.js=new JScrollPane(tab); mainUI.jp.add(mainUI.js,BorderLayout.SOUTH); } }); } protected void paintComponent(Graphics g){ ImageIcon icon=new ImageIcon("F:/人机界面第一次设计/成果/图片/查询影片.jpg"); super.paintComponent(g); ImageObserver ll = null; g.drawImage(icon.getImage(),0,0,mainUI.jp.getWidth(),mainUI.jp.getHeight(),ll); } }因为只是界面,所以只是简单的演示点击查询后出现什么,点击返回则到主界面
package 剧院管理界面; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Area; import java.awt.image.ImageObserver; import java.util.Vector; import javax.swing.*; import javax.swing.border.LineBorder; import javax.swing.table.DefaultTableModel; public class addMovie extends JPanel{ GridBagLayout layout=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); JLabel jl1=new JLabel("电影名称"); JLabel jl2=new JLabel("影片票价"); JLabel jl3=new JLabel("放映时间"); JLabel jl4=new JLabel("放映大厅"); JLabel jl5=new JLabel("具体介绍"); JTextField jt1=new JTextField(10); JTextField jt2=new JTextField(10); JTextField jt3=new JTextField(10); JTextField jt4=new JTextField(10); JTextArea jt5=new JTextArea(2,10); JButton button2=new JButton("添加"); JButton button3=new JButton("返回"); public addMovie(){ setLayout(layout); jt5.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jl1,gbc); jl1.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jt1,gbc); gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=1; gbc.gridheight=1; add(jl2,gbc); jl2.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=1; gbc.gridwidth=1; gbc.gridheight=1; add(jt2,gbc); gbc.gridx=0; gbc.gridy=2; gbc.gridwidth=1; gbc.gridheight=1; add(jl3,gbc); jl3.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=1; gbc.gridheight=1; add(jt3,gbc); gbc.gridx=0; gbc.gridy=3; gbc.gridwidth=1; gbc.gridheight=1; add(jl4,gbc); jl4.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; gbc.gridheight=1; add(jt4,gbc); gbc.gridx=0; gbc.gridy=4; gbc.gridwidth=1; gbc.gridheight=1; add(jl5,gbc); jl5.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=4; gbc.gridwidth=1; gbc.gridheight=1; add(jt5,gbc); gbc.gridx=0; gbc.gridy=5; gbc.gridwidth=1; gbc.gridheight=1; gbc.gridx=0; gbc.gridy=11; gbc.gridwidth=1; gbc.gridheight=1; button2.setFont(new Font("宋体", Font.BOLD, 20)); add(button2,gbc); gbc.gridx=1; gbc.gridy=11; gbc.gridwidth=1; gbc.gridheight=1; button3.setFont(new Font("宋体", Font.BOLD, 20)); add(button3,gbc); JFrame add=new JFrame(); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { add.setVisible(true); } }); JButton succ=new JButton("添加成功"); succ.setFont(new Font("宋体", Font.BOLD, 20)); add.add(succ); add.setLocationRelativeTo(null); add.setSize(100,100); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainUI.jp.removeAll(); mainUI.jp.updateUI(); mainUI.jp.setVisible(true); //mainUI.jp.add(new BackGround()); Vector bt = new Vector(); bt.add("电影名"); bt.add("放映场次"); bt.add("放映厅"); bt.add("票价"); bt.add("影片状态"); Vector data1 = new Vector(); data1.add("疯狂动物城"); data1.add("7:30,11:20,14:00,18:45"); data1.add("一号厅"); data1.add("30"); data1.add("正在热映"); Vector data2 = new Vector(); data2.add("叶问3"); data2.add("6:30,12:20,14:30"); data2.add("二号厅"); data2.add("25"); data2.add("即将下架"); Vector data3 = new Vector(); data3.add("荒野猎人"); data3.add("8:00,10:30,13:00,17:25"); data3.add("一号厅"); data3.add("30"); data3.add("正在热映"); Vector data4 = new Vector(); data4.add("美人鱼"); data4.add("9:20,10:30,11:20,12:45,16:00,20:45"); data4.add("三号厅"); data4.add("30"); data4.add("正在热映"); Vector data5 = new Vector(); data5.add("澳门风云3"); data5.add("9:00,15:20"); data5.add("四号厅"); data5.add("25"); data5.add("即将下架"); Vector data6 = new Vector(); data6.add("蝙蝠侠大战超人:正义黎明"); data6.add("8:20,13:20,15:10,17:25"); data6.add("一号厅"); data6.add("30"); data6.add("马上公映"); Vector data7 = new Vector(); data7.add("神战:权力之眼"); data7.add("7:30,18:45"); data7.add("二号厅"); data7.add("30"); data7.add("即将下架"); Vector data8 = new Vector(); data8.add("女汉子真爱公式"); data8.add("9:30,13:00,16:45"); data8.add("三号厅"); data8.add("30"); data8.add("正在热映"); Vector data9 = new Vector(); data9.add("功夫熊猫3"); data9.add("7:40,10:20,11:20,14:00,18:45"); data9.add("一号厅"); data9.add("30"); data9.add("正在热映"); Vector data10 = new Vector(); data10.add("我的特工爷爷"); data10.add("9:20,12:30,16:00,18:55"); data10.add("三号厅"); data10.add("30"); data10.add("马上公映"); Vector data11 = new Vector(); data11.add("火影忍者:博人传"); data11.add("7:50,12:20,15:00,20:45"); data11.add("二号厅"); data11.add("30"); data11.add("正在热映"); Vector data12 = new Vector(); data12.add("老炮儿"); data12.add("9:10,12:40,15:10,21:45"); data12.add("一号厅"); data12.add("30"); data12.add("即将下架"); Vector datas = new Vector(); datas.add(data2); datas.add(data5); datas.add(data7); datas.add(data12); datas.add(data1); datas.add(data3); datas.add(data4); datas.add(data8); datas.add(data9); datas.add(data11); datas.add(data6); datas.add(data10); DefaultTableModel dd=new DefaultTableModel(datas, bt); JTable tab = new JTable(); tab.setModel(dd); tab.setFont(new Font("Menu.font", Font.PLAIN, 25)); tab.setRowHeight(30); mainUI.js=new JScrollPane(tab); mainUI.jp.add(mainUI.js,BorderLayout.SOUTH); } }); } protected void paintComponent(Graphics g){ ImageIcon icon=new ImageIcon("F:/人机界面第一次设计/成果/图片/添加影片.jpg"); super.paintComponent(g); ImageObserver ll = null; g.drawImage(icon.getImage(),0,0,mainUI.jp.getWidth(),mainUI.jp.getHeight(),ll); } }
JTabbedPane tp=new JTabbedPane(); showRoomInfo con=new showRoomInfo(); showRoomInfo1 con1=new showRoomInfo1(); showRoomInfo2 con2=new showRoomInfo2(); JPanel f3=new JPanel(); JPanel f4=new JPanel(); tp.setTabPlacement(JTabbedPane.LEFT); tp.addTab("一号厅",con); tp.addTab("二号厅",con1); tp.addTab("三号厅",con2); tp.addTab("四号厅", f3); tp.addTab("五号厅", f4);
package 剧院管理界面; import java.awt.Component; import java.awt.Font; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.image.ImageObserver; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class showRoomInfo extends JPanel{ public showRoomInfo(){ GridBagLayout lay=new GridBagLayout(); setLayout(lay); JLabel movies=new JLabel("所放电影"); movies.setFont(new Font("宋体",Font.BOLD, 30)); JLabel times=new JLabel("场次分布"); times.setFont(new Font("宋体",Font.BOLD, 30)); JLabel m1=new JLabel("疯狂动物城"); m1.setFont(new Font("楷体",Font.BOLD, 20)); JLabel m2=new JLabel("美人鱼"); m2.setFont(new Font("楷体",Font.BOLD, 20)); JLabel m3=new JLabel("荒野猎人"); m3.setFont(new Font("楷体",Font.BOLD, 20)); JLabel m4=new JLabel("火影忍者:博人传"); m4.setFont(new Font("楷体",Font.BOLD, 20)); JLabel m5=new JLabel("澳门风云3"); m5.setFont(new Font("楷体",Font.BOLD, 20)); JLabel t1=new JLabel("7:30,11:20,14:00,18:45"); t1.setFont(new Font("宋体",Font.BOLD, 20)); JLabel t2=new JLabel("8:00,10:45"); t2.setFont(new Font("宋体",Font.BOLD, 20)); JLabel t3=new JLabel("9:50,12:00,15:35"); t3.setFont(new Font("宋体",Font.BOLD, 20)); JLabel t4=new JLabel("9:50,14:00,10:45"); t4.setFont(new Font("宋体",Font.BOLD, 20)); JLabel t5=new JLabel("9:50,14:00,10:45"); t5.setFont(new Font("宋体",Font.BOLD, 20)); GridBagConstraints cons=new GridBagConstraints(); cons.fill=GridBagConstraints.NONE; cons.weightx=6; cons.weighty=6; add(movies,cons,1,1,1,1); add(times,cons,3,1,1,1); add(m1,cons,1,2,1,1); add(t1,cons,3,2,1,1); add(m2,cons,1,3,1,1); add(t2,cons,3,3,1,1); add(m3,cons,1,4,1,1); add(t3,cons,3,4,1,1); add(m4,cons,1,5,1,1); add(t4,cons,3,5,1,1); add(m5,cons,1,6,1,1); add(t5,cons,3,6,1,1); } public void add(Component c,GridBagConstraints con,int x,int y,int w,int h) { con.gridx=x; con.gridy=y; con.gridwidth=w; con.gridheight=h; add(c,con); } protected void paintComponent(Graphics g){ ImageIcon icon=new ImageIcon("F:/人机界面第一次设计/成果/图片/放映厅.jpg"); super.paintComponent(g); ImageObserver ll = null; g.drawImage(icon.getImage(),0,0,mainUI.jp.getWidth(),mainUI.jp.getHeight(),ll); } }
package 剧院管理界面; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.ImageObserver; import java.util.Vector; import javax.swing.*; import javax.swing.table.DefaultTableModel; public class dataCount extends JPanel{ GridBagLayout layout=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); JLabel jl1=new JLabel("上映片数"); JLabel jl2=new JLabel("观影人数"); JLabel jl3=new JLabel("今日收入"); JLabel jl4=new JLabel("影片排行"); JLabel jt1=new JLabel("4"); JLabel jt2=new JLabel("327"); JLabel jt3=new JLabel("¥9830"); JLabel jt4=new JLabel(" No.1:疯狂动物城"); JLabel jt5=new JLabel(" No.2:叶问"); JLabel jt6=new JLabel(" No.3:荒野猎人"); JButton button2=new JButton("修改"); JButton button3=new JButton("返回"); public dataCount(){ setLayout(layout); gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jl1,gbc); jl1.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; add(jt1,gbc); jt1.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=1; gbc.gridheight=1; add(jl2,gbc); jl2.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=1; gbc.gridwidth=1; gbc.gridheight=1; add(jt2,gbc); jt2.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=0; gbc.gridy=2; gbc.gridwidth=1; gbc.gridheight=1; add(jl3,gbc); jl3.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=1; gbc.gridheight=1; add(jt3,gbc); jt3.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=0; gbc.gridy=3; gbc.gridwidth=1; gbc.gridheight=1; add(jl4,gbc); jl4.setFont(new Font("宋体",Font.BOLD, 30)); gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; gbc.gridheight=1; add(jt4,gbc); jt4.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=1; gbc.gridy=4; gbc.gridwidth=1; gbc.gridheight=1; add(jt5,gbc); jt5.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=1; gbc.gridy=5; gbc.gridwidth=1; gbc.gridheight=1; add(jt6,gbc); jt6.setFont(new Font("宋体",Font.BOLD, 25)); gbc.gridx=0; gbc.gridy=11; gbc.gridwidth=1; gbc.gridheight=1; button2.setFont(new Font("宋体", Font.BOLD, 20)); add(button2,gbc); gbc.gridx=1; gbc.gridy=11; gbc.gridwidth=1; gbc.gridheight=1; button3.setFont(new Font("宋体", Font.BOLD, 20)); add(button3,gbc); JFrame change=new JFrame(); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { change.setVisible(true); } }); change.setLayout(new GridLayout(7,2,5,5)); JLabel j7=new JLabel("上映片数:"); j7.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j7); change.add(new JTextField(10)); JLabel j6=new JLabel("观影人数:"); j6.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j6); change.add(new JTextField(10)); JLabel j5=new JLabel("今日收入"); j5.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j5); change.add(new JTextField(10)); JLabel j4=new JLabel("影片No.1:"); j4.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j4); change.add(new JTextField(10)); JLabel j3=new JLabel("影片No.2:"); j3.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j3); change.add(new JTextField(10)); JLabel j2=new JLabel("影片No.3:"); j2.setFont(new Font("宋体", Font.BOLD, 33)); change.add(j2); change.add(new JTextField(10)); change.add(new JLabel()); JButton ok=new JButton("确定"); ok.setFont(new Font("宋体", Font.BOLD, 20)); change.add(ok); change.setSize(500, 400); change.setLocationRelativeTo(null); JFrame OK=new JFrame(); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OK.setVisible(true); } }); JButton cs=new JButton("修改成功"); cs.setFont(new Font("宋体", Font.BOLD, 20)); OK.add(cs); OK.setLocationRelativeTo(null); OK.setSize(100,100); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainUI.jp.removeAll(); mainUI.jp.updateUI(); mainUI.jp.setVisible(true); Vector bt = new Vector(); bt.add("电影名"); bt.add("放映场次"); bt.add("放映厅"); bt.add("票价"); bt.add("影片状态"); Vector data1 = new Vector(); data1.add("疯狂动物城"); data1.add("7:30,11:20,14:00,18:45"); data1.add("一号厅"); data1.add("30"); data1.add("正在热映"); Vector data2 = new Vector(); data2.add("叶问3"); data2.add("6:30,12:20,14:30"); data2.add("二号厅"); data2.add("25"); data2.add("即将下架"); Vector data3 = new Vector(); data3.add("荒野猎人"); data3.add("8:00,10:30,13:00,17:25"); data3.add("一号厅"); data3.add("30"); data3.add("正在热映"); Vector data4 = new Vector(); data4.add("美人鱼"); data4.add("9:20,10:30,11:20,12:45,16:00,20:45"); data4.add("三号厅"); data4.add("30"); data4.add("正在热映"); Vector data5 = new Vector(); data5.add("澳门风云3"); data5.add("9:00,15:20"); data5.add("四号厅"); data5.add("25"); data5.add("即将下架"); Vector data6 = new Vector(); data6.add("蝙蝠侠大战超人:正义黎明"); data6.add("8:20,13:20,15:10,17:25"); data6.add("一号厅"); data6.add("30"); data6.add("马上公映"); Vector data7 = new Vector(); data7.add("神战:权力之眼"); data7.add("7:30,18:45"); data7.add("二号厅"); data7.add("30"); data7.add("即将下架"); Vector data8 = new Vector(); data8.add("女汉子真爱公式"); data8.add("9:30,13:00,16:45"); data8.add("三号厅"); data8.add("30"); data8.add("正在热映"); Vector data9 = new Vector(); data9.add("功夫熊猫3"); data9.add("7:40,10:20,11:20,14:00,18:45"); data9.add("一号厅"); data9.add("30"); data9.add("正在热映"); Vector data10 = new Vector(); data10.add("我的特工爷爷"); data10.add("9:20,12:30,16:00,18:55"); data10.add("三号厅"); data10.add("30"); data10.add("马上公映"); Vector data11 = new Vector(); data11.add("火影忍者:博人传"); data11.add("7:50,12:20,15:00,20:45"); data11.add("二号厅"); data11.add("30"); data11.add("正在热映"); Vector data12 = new Vector(); data12.add("老炮儿"); data12.add("9:10,12:40,15:10,21:45"); data12.add("一号厅"); data12.add("30"); data12.add("即将下架"); Vector datas = new Vector(); datas.add(data2); datas.add(data5); datas.add(data7); datas.add(data12); datas.add(data1); datas.add(data3); datas.add(data4); datas.add(data8); datas.add(data9); datas.add(data11); datas.add(data6); datas.add(data10); DefaultTableModel dd=new DefaultTableModel(datas, bt); JTable tab = new JTable(); tab.setModel(dd); tab.setFont(new Font("Menu.font", Font.PLAIN, 25)); tab.setRowHeight(30); mainUI.js=new JScrollPane(tab); mainUI.jp.add(mainUI.js,BorderLayout.SOUTH); } }); } protected void paintComponent(Graphics g){ ImageIcon icon=new ImageIcon("F:/人机界面第一次设计/成果/图片/数据统计.png"); super.paintComponent(g); ImageObserver ll = null; g.drawImage(icon.getImage(),0,0,mainUI.jp.getWidth(),mainUI.jp.getHeight(),ll); } }
以上就是我负责的部分,其实还有一半功劳需要算在组员马兄的身上,他算是我们小组的技术顾问,明天也将会看到他写的部分。
标签:
原文地址:http://blog.csdn.net/zy_dream/article/details/51001972