标签:可见 push app wince etl 找不到 += 用户 ret
实验十八 总复习
实验时间 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 AA;
2
3 import java.awt.Dimension;
4 import java.awt.Toolkit;
5 import java.awt.Window;
6
7 public class WinCenter {
8 public static void center(Window win){
9 Toolkit tkit = Toolkit.getDefaultToolkit();
10 Dimension sSize = tkit.getScreenSize();
11 Dimension wSize = win.getSize();
12 if(wSize.height > sSize.height){
13 wSize.height = sSize.height;
14 }
15 if(wSize.width > sSize.width){
16 wSize.width = sSize.width;
17 }
18 win.setLocation((sSize.width - wSize.width)/ 2, (sSize.height - wSize.height)/ 2);
19 }
20 }
1 package AA;
2
3 import java.awt.Dimension;
4 import java.awt.FlowLayout;
5 import java.awt.GridLayout;
6
7 import javax.swing.BorderFactory;
8 import javax.swing.ButtonGroup;
9 import javax.swing.JButton;
10 import javax.swing.JCheckBox;
11 import javax.swing.JComboBox;
12 import javax.swing.JFrame;
13 import javax.swing.JLabel;
14 import javax.swing.JPanel;
15 import javax.swing.JRadioButton;
16 import javax.swing.JTextField;
17
18 public class DemoJFrame extends JFrame {
19 private JPanel jPanel1;
20 private JPanel jPanel2;
21 private JPanel jPanel3;
22 private JPanel jPanel4;
23 private JTextField fieldname;
24 private JComboBox comboBox;
25 private JTextField fieldadress;
26 private ButtonGroup bg;
27 private JRadioButton Male;
28 private JRadioButton Female;
29 private JCheckBox read;
30 private JCheckBox sing;
31 private JCheckBox dance;
32
33 public DemoJFrame() {
34 // 设置窗口大小
35 this.setSize(800, 400);
36 // 设置可见性
37 this.setVisible(true);
38 // 设置标题
39 this.setTitle("编程练习一");
40 // 设置关闭操作
41 this.setDefaultCloseOperation(EXIT_ON_CLOSE);
42 // 设置窗口居中
43 WinCenter.center(this);
44 // 创建四个面板对象
45 jPanel1 = new JPanel();
46 setJPanel1(jPanel1);
47 jPanel2 = new JPanel();
48 setJPanel2(jPanel2);
49 jPanel3 = new JPanel();
50 setJPanel3(jPanel3);
51 jPanel4 = new JPanel();
52 setJPanel4(jPanel4);
53 // 设置容器的为流布局
54 FlowLayout flowLayout = new FlowLayout();
55 this.setLayout(flowLayout);
56 // 将四个面板添加到容器中
57 this.add(jPanel1);
58 this.add(jPanel2);
59 this.add(jPanel3);
60 this.add(jPanel4);
61
62 }
63
64 /*
65 * 设置面一
66 */
67 private void setJPanel1(JPanel jPanel) {
68 // TODO 自动生成的方法存根
69 jPanel.setPreferredSize(new Dimension(700, 45));
70 // 给面板的布局设置为网格布局 一行4列
71 jPanel.setLayout(new GridLayout(1, 4));
72
73 JLabel name = new JLabel("name:");
74 name.setSize(100, 50);
75 fieldname = new JTextField("");
76 fieldname.setSize(80, 20);
77
78 JLabel study = new JLabel("qualification:");
79 comboBox = new JComboBox();
80 comboBox.addItem("初中");
81 comboBox.addItem("高中");
82 comboBox.addItem("本科");
83 jPanel.add(name);
84 jPanel.add(fieldname);
85 jPanel.add(study);
86 jPanel.add(comboBox);
87
88 }
89
90 /*
91 * 设置面板二
92 */
93 private void setJPanel2(JPanel jPanel) {
94 // TODO 自动生成的方法存根
95 jPanel.setPreferredSize(