大连东软信息学院企业业务开发实践实验报告系别:信息管理系专业班级:信息学号:151学生姓名:指导教师:张奇松2015年8月17日企业业务开发实践一、GUI基础知识习题1.图形界面1.1实验目的学习GUI,主要是Swing程序设计,包括常用窗体,标签组件和图表,常用布局管理器,常用面板,按钮组件,文本组件以及事件监听器等。1.2实验代码及运行结果(运行结果截图)1.创建一个窗体,布局如图所示,窗体大小为300,200setBounds(100,100,300,200);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));contentPane.setLayout(newBorderLayout(0,0));setContentPane(contentPane);JLabellblswing=newJLabel(\u4F60\u597D\uFF0CSwing);contentPane.add(lblswing,BorderLayout.WEST);2.创建一个窗体,布局如图所示,窗体大小为200,120contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));setContentPane(contentPane);contentPane.setLayout(null);JButtonbtnNewButton=newJButton(\u5DE6);btnNewButton.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){企业业务开发实践btnNewButton.setBounds(31,68,71,38);contentPane.add(btnNewButton);JButtonbtnNewButton_1=newJButton(\u4E2D\u95F4);btnNewButton_1.setBounds(135,68,84,38);contentPane.add(btnNewButton_1);JButtonbtnNewButton_2=newJButton(\u53F3);btnNewButton_2.setBounds(255,68,61,38);contentPane.add(btnNewButton_2);JCheckBoxcheckBox=newJCheckBox(\u5DE6);checkBox.setBounds(31,161,71,23);contentPane.add(checkBox);JCheckBoxcheckBox_1=newJCheckBox(\u53F3);checkBox_1.setBounds(100,161,80,23);contentPane.add(checkBox_1);JRadioButtonradioButton=newJRadioButton(\u5DE6);radioButton.setBounds(182,161,83,23);contentPane.add(radioButton);JRadioButtonradioButton_1=newJRadioButton(\u53F3);radioButton_1.setBounds(267,161,84,23);contentPane.add(radioButton_1);3.创建一个窗体,布局如图所示,窗体大小为300,120setTitle(\u7EFC\u5408\u4F8B\u7A0B);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,300,120);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));setContentPane(contentPane);企业业务开发实践contentPane.setLayout(null);JListlist_1=newJList();list_1.setBounds(251,114,29,-17);contentPane.add(list_1);JComboBoxcomboBox=newJComboBox();comboBox.setModel(newDefaultComboBoxModel(newString[]{\u9009\u9879\u4E00,\u9009\u9879\u4E8C,\u9009\u9879\u4E09}));comboBox.setBounds(23,22,65,28);contentPane.add(comboBox);JListlist=newJList();list.setModel(newAbstractListModel(){String[]values=newString[]{\u9009\u9879\u4E00,\u9009\u9879\u4E8C,\u9009\u9879\u4E09};publicintgetSize(){returnvalues.length;}publicObjectgetElementAt(intindex){returnvalues[index];}});list.setBounds(98,10,50,61);contentPane.add(list);JListlist_3=newJList();list_3.setBounds(279,33,-9,51);contentPane.add(list_3);JListlist_2=newJList();list_2.setBounds(309,114,1,1);contentPane.add(list_2);JScrollPanescrollPane=newJScrollPane();scrollPane.setBounds(169,6,50,61);contentPane.add(scrollPane);JTextAreatextArea=newJTextArea();textArea.setText(1\r\n2\r\n3\r\n4\r\n5);scrollPane.setViewportView(textArea);企业业务开发实践4.创建一个登录界面,布局如图所示,窗体大小为300,200setTitle(\u767B\u5F55\u754C\u9762);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,300,200);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));setContentPane(contentPane);contentPane.setLayout(null);JLabellabel=newJLabel(\u7528\u6237\u540D\uFF1A);label.setBounds(21,47,54,15);contentPane.add(label);JLabellabel_1=newJLabel(\u5BC6\u7801\uFF1A);label_1.setBounds(21,72,54,15);contentPane.add(label_1);JTextAreatextArea=newJTextArea();textArea.setBounds(68,43,104,19);contentPane.add(textArea);JTextAreatextArea_1=newJTextArea();textArea_1.setBounds(68,72,104,15);contentPane.add(textArea_1);JButtonbutton=newJButton(\u767B\u5F55);button.setBounds(10,114,93,23);contentPane.add(button);JButtonbutton_1=newJButton(\u91CD\u7F6E);button_1.setBounds(130,114,93,23);contentPane.add(button_1);企业业务开发实践5.创建一个窗体,布局如图所示,窗体大小为500,300setTitle(e\u5FAE\u8FDB\u9500\u5B58\u7BA1\u7406\u7CFB\u7EDF);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,500,300);JMenuBarmenuBar=newJMenuBar();setJMenuBar(menuBar);JMenumenu=newJMenu(\u6587\u4EF6);menuBar.add(menu);JMenuItemmenuItem=newJMenuItem(\u65B0\u5EFA);menu.add(menuItem);JMenuItemmenuItem_1=newJMenuItem(\u6253\u5F00);menu.add(menuItem_1);JMenuItemmenuItem_2=newJMenuItem(\u4FDD\u5B58);menu.add(menuItem_2);JMenuItemmenuItem_3=newJMenuItem(\u9000\u51FA);menu.add(menuItem_3);JMenumenu_1=newJMenu(\u5546\u54C1\u7BA1\u7406);menuBar.add(menu_1);企业业务开发实践JMenuItemmntmNewMenuItem=newJMenuItem(\u5546\u54C1\u67E5\u8BE2);menu_1.add(mntmNewMenuItem);JMenuItemmenuItem_4=newJMenuItem(\u5546\u54C1\u6DFB\u52A0);menu_1.add(menuItem_4);JMenuItemmntmNewMenuItem_1=newJMenuItem(\u5546\u54C1\u4FEE\u6539);menu_1.add(mntmNewMenuItem_1);JMenuItemmenuItem_5=newJMenuItem(\u5546\u54C1\u5220\u9664);menu_1.add(menuItem_5);JMenumenu_2=newJMenu(\u4F9B\u5E94\u5546);menuBar.add(menu_2);JMenuItemmenuItem_6=newJMenuItem(\u7F16\u8F91\u4F9B\u5E94\u5546);menu_2.add(menuItem_6);JMenumenu_3=newJMenu(\u7528\u6237);menuBar.add(menu_3);JMenuItemmenuItem_7=newJMenuItem(\u7F16\u8F91\u7528\u6237);menu_3.add(menuItem_7);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));contentPane.setLayout(newBorderLayout(0,0));setContentPane(contentPane);企业业务开发实践企业业务开发实践2.Java基础知识回顾2.1