JAVA小程序—学生点名系统
2018-01-08 20:45
295 查看
写在前面,因为用的Mac OS ,所以eclipse运行显示为Mac OS风格。
先放效果图
这里写图片描述
程序算法十分简单,刚刚学完JAVA-GUI编程,就小试牛刀,学的过时的AWT,而且API文档也没怎么看就心急赶紧做了这么个小东西。
具体代码实现如下:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
先放效果图
这里写图片描述
程序算法十分简单,刚刚学完JAVA-GUI编程,就小试牛刀,学的过时的AWT,而且API文档也没怎么看就心急赶紧做了这么个小东西。
具体代码实现如下:
import java.awt.*; import java.awt.event.*; import java.util.*; public class TestKeyborad { public static void main(String []args){ MyFrame f = new MyFrame(); f.launchFrame(); } } class MyFrame extends Frame{ Label text2; void launchFrame(){ setTitle("学生点名系统"); setVisible(true); Butto 4000 n btn1 = new Button("开始"); Button btn2 = new Button("结束"); Label text1 = new Label("学号:"); text2 = new Label("按下开始按钮开始点名"); Panel p=new Panel(); setBounds(300,300,300,400); p.setBackground(Color.white); p.setBounds(0,0,300,400); p.setLayout(new FlowLayout(FlowLayout.CENTER,60,100)); //btn1.setBounds(20,20,50,20); //btn2.setBounds(90,20,50,20); add(p); p.add(text1); p.add(text2); p.add(btn1); p.add(btn2); this.addWindowListener(new MyWindowMoniter()); btn1.addActionListener(new btnMoniter(this)); btn2.addActionListener(new btnMoniter(this)); } } class btnMoniter implements ActionListener { MyFrame f; btnMoniter(MyFrame f){ this.f=f; } public void actionPerformed(ActionEvent e){ String s=e.getActionCommand(); Random r=new Random(); int i=r.nextInt(50); if(s=="开始"){ f.repaint(); f.text2.setText("正在点名!"); } if(s=="结束"){ f.repaint(); f.text2.setText(""+i); } } } //window时间监听器,用于关闭window窗口 class MyWindowMoniter extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
第一次认真的写CSDN博客,好多东西都没去研究。排版也比较垃圾。文章写的也毫无文采可言。 最重要的是:程序实现不是很好,刚刚从面向过程语言转面向对象语言。缺乏面对对象思维。 这是本人第一个JAVA桌面程序。
相关文章推荐
- [置顶] JAVA小程序—学生点名系统
- Java程序综合案例:教务处管理系统之学生档案管理模块
- Java程序---学生管理系统的登录和注册
- java学生管理系统(GUI)---第二个java文件(接上面的java程序,被调用的窗口)
- java 小程序之随机点名系统
- JAVA实现用系统关联的程序打开文件
- 使用Java Service Wrapper 把Java程序作为Windows系统服务
- flash中通过XMLSocket监控生产系统 java服务器端程序(1)
- Java 的系统程序包
- JAVA 程序中如何拷贝一个目录下的文件及子目录到另一个目录,如何获取系统环境变量等...
- flash中通过XMLSocket监控生产系统 java服务器端程序(2)
- Windows系统托盘图标程序之Java实现
- PB学习笔记之二pb程序系统分析学生信息管理系统
- Java程序性能优化总结--------线程、I/O及系统篇
- 使用JavaService让java程序加载为winNT系统服务
- 将Java程序变成Windows系统服务-Java基础-Java-编程开发
- JAVA写的学生成绩管理系统
- [老文章转载]将Java程序变成Windows系统服务
- Windows环境下注册Java程序为系统服务
- Java调用系统执行程序(OS Command)