第一部分:理论知识学习部分
总复习纲要
1. Java语言特点与开发环境配置(第1章、第2章)
2. Java基本程序结构(第3章)
3. Java面向对象程序结构(第4章、第5章、第6章)
4. 类、类间关系、类图
5. Java JDK预定义类/接口及其API(String-第3章、 Arrays-第3章、Files-第3章62页、LocalDate-第4章、 Object-第5章、对象包装器-第5章、Comparator-第6章、 异常类-第7章、ArrayList-第5+8章、第9章、第10-12章、 第14章)
— Java异常处理编程模型
— Java GUI编程模型
6. Java并发程序设计(第14章)
7. Java应用程序部署(第13章)
第二部分:实验部分——实验十八 总复习
实验时间 2018-12-30
1、实验目的与要求
(1) 综合掌握java基本程序结构;
(2) 综合掌握java面向对象程序设计特点;
(3) 综合掌握java GUI 程序设计结构;
(4) 综合掌握java多线程编程模型;
(5) 综合编程练习。
2、实验内容和步骤
任务1:填写课程课后调查问卷,网址:https://www.wjx.cn/jq/33108969.aspx。
任务2:综合编程练习
练习1:设计一个用户信息采集程序,要求如下:
(1) 用户信息输入界面如下图所示:
(1)用户点击提交按钮时,用户输入信息显示控制台界面;
(2)用户点击重置按钮后,清空用户已输入信息;
(3)点击窗口关闭,程序退出。
1 package jiemian; 2 3 import java.awt.EventQueue; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 7 import javax.swing.ButtonGroup; 8 import javax.swing.JButton; 9 import javax.swing.JCheckBox; 10 import javax.swing.JComboBox; 11 import javax.swing.JFrame; 12 import javax.swing.JLabel; 13 import javax.swing.JPanel; 14 import javax.swing.JRadioButton; 15 import javax.swing.JTextArea; 16 17 public class aaa { 18 19 public static void main(String[] args) { 20 EventQueue.invokeLater(() -> { 21 JFrame frame = new FrameTest(); 22 frame.setTitle("WangZT"); 23 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 24 frame.setVisible(true); 25 }); 26 } 27 } 28 class FrameTest extends JFrame { 29 30 private JPanel panel; 31 private JRadioButton JRadioButton1,JRadioButton2; 32 private ButtonGroup ButtonGroup; 33 private JLabel JLabel; 34 private JTextArea fieldname,fieldadress; 35 private JCheckBox Read,dance,sing; 36 private JComboBox<String> JComboBox; 37 private JButton Button1,Button2; 38 public FrameTest() { 39 setSize(700,500); 40 panel=new JPanel(); 41 panel.setLayout(null); 42 ButtonGroup=new ButtonGroup(); 43 JRadioButton1=new JRadioButton("男",false); JRadioButton1.setBounds(130,330, 80, 50); 44 JRadioButton2=new JRadioButton("女",false); JRadioButton2.setBounds(130,300, 80,50); 45 ButtonGroup.add(JRadioButton1); 46 ButtonGroup.add(JRadioButton2); 47 addJLabel("性别:",100,300); 48 addJLabel("姓名:",100,50); 49 addJLabel("地址:",90,150); 50 addJLabel("资格:",400,50); 51 addJLabel("喜好:",400,150); 52 53 fieldname=new JTextArea(1,1);fieldname.setBounds(150,70, 120, 30);fieldname.setLineWrap(true); 54 fieldadress=new JTextArea(5,3);fieldadress.setBounds(150,160, 130, 100);fieldadress.setLineWrap(true); 55 Read=new JCheckBox("读书");Read.setBounds(450,160,100,30); 56 dance=new JCheckBox("跳舞");dance.setBounds(450,180,100,30); 57 sing=new JCheckBox("唱歌");sing.setBounds(450,200,100,30); 58 JComboBox=new JComboBox<>(); 59 JComboBox.addItem("研究生"); 60 JComboBox.addItem("本科生"); 61 JComboBox.addItem("专科生"); 62 JComboBox.setBounds(500,65, 100, 20); 63 Button1 = new JButton("提交");Button1.setBounds(200, 400, 100, 35); 64 Button2 = new JButton("重置");Button2.setBounds(400, 400, 100, 35); 65 Button1.addActionListener(new Action1()); 66 Button2.addActionListener(new Action2()); 67 68 panel.add(Button2); 69 panel.add(Button1); 70 panel.add(JComboBox); 71 panel.add(Read); 72 panel.add(dance); 73 panel.add(sing); 74 panel.add(fieldname); 75 panel.add(fieldadress); 76 panel.add(JRadioButton1); 77 panel.add(JRadioButton2); 78 add(panel); 79 } 80 81 82 public void addJLabel(String n,int a,int b) { 83 JLabel = new JLabel(n); 84 JLabel.setBounds(a,b,100,50); 85 panel.add(JLabel); 86 } 87 88 private class Action1 implements ActionListener { 89 public void actionPerformed(ActionEvent event) { 90 System.out.println("name:"+fieldname.getText()+"\n"+"address:"+fieldadress.getText()); 91 System.out.println("Qualification:"+JComboBox.getSelectedItem()); 92 System.out.println("Hobby:"); 93 if(Read.isSelected()==true)System.out.print(Read.getText()); 94 if(dance.isSelected()==true)System.out.print(dance.getText()); 95 if(sing.isSelected()==true)System.out.print(sing.getText()); 96 System.out.println("\n"+"sex:"); 97 if(JRadioButton1.isSelected()==true)System.out.println(JRadioButton1.getText()); 98 if(JRadioButton2.isSelected()==true)System.out.println(JRadioButton2.getText()); 99 System.out.println("\n"); 100 } 101 } 102 private class Action2 implements ActionListener { 103 public void actionPerformed(ActionEvent event) { 104 fieldname.setText(null); 105 fieldadress.setText(null); 106 Read.setSelected(false); 107 dance.setSelected(false); 108 sing.setSelected(false); 109 ButtonGroup.clearSelection(); 110 JComboBox.setSelectedIndex(0); 111 } 112 } 113 114 }