資源簡介
用java語言實現課堂點名軟件,即點名系統

代碼片段和文件信息
package?edu.zte.j2se.io;
import?java.awt.*;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.objectOutputStream;
import?java.util.ArrayList;
import?java.util.Calendar;
import?java.util.Random;
import?javax.swing.*;
public?class?frame1?extends?Jframe?{
JPanel?contentPane;
BorderLayout?borderLayout1?=?new?BorderLayout();
JLabel?lblTimeDis?=?new?JLabel();
JLabel?lblNewsDis?=?new?JLabel();
JTextField?txtNameDis?=?new?JTextField();
int?a?x;//a表示一個隨機數x表示當前未被點過的人數
String?name;
JButton?btnStart?=?new?JButton();
JButton?btnEnd?=?new?JButton();
SaveReadStu?r?=?new?SaveReadStu();
//?Students[]?arrName=(Students[])r.read();
Students[]?ss?=?r.s;
Timer?t1?=?new?Timer(1?new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
ArrayList?arrName?=?(ArrayList)?r.readNoCall();
Random?ran?=?new?Random();
x?=?arrName.size();
System.out.println(“x========“?+?x);
a?=?ran.nextInt(x);
name?=?arrName.get(a).toString();
//?txtNameDis.setText(arrName[a].toString());
txtNameDis.setText(arrName.get(a).toString());
}
});
public?frame1()?{
try?{
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
}?catch?(Exception?exception)?{
exception.printStackTrace();
}
}
private?void?jbInit()?throws?Exception?{
contentPane?=?(JPanel)?getContentPane();
contentPane.setLayout(null);
setSize(new?Dimension(400?300));
settitle(“@無敵幸運星@“);
this.getTime();
lblTimeDis.setFont(new?java.awt.Font(“Dialog“?Font.PLAIN?15));
lblTimeDis.setBounds(new?Rectangle(30?24?320?15));
lblTimeDis.setText(getTime());
txtNameDis.setFont(new?java.awt.Font(“Dialog“?Font.PLAIN?15));
txtNameDis.setText(““);
txtNameDis.setBounds(new?Rectangle(140?68?79?18));
lblNewsDis.setFont(new?java.awt.Font(“Dialog“?Font.PLAIN?15));
lblNewsDis.setText(“準備好了嗎?同學們“);
lblNewsDis.setBounds(new?Rectangle(120?100?200?18));
btnStart.setBounds(new?Rectangle(100?130?71?19));
btnStart.setFont(new?java.awt.Font(“Dialog“?Font.PLAIN?15));
btnStart.setText(“開始“);
btnStart.addActionListener(new?frame1BtnStartActionAdapter(this));
btnEnd.setBounds(new?Rectangle(205?129?73?19));
btnEnd.setFont(new?java.awt.Font(“Dialog“?Font.PLAIN?15));
btnEnd.setText(“結束“);
btnEnd.addActionListener(new?frame1BtnEndActionAdapter(this));
contentPane.add(txtNameDis);
contentPane.add(btnStart);
contentPane.add(btnEnd);
contentPane.add(lblTimeDis);
contentPane.add(lblNewsDis);
Timer?tiTime?=?new?Timer(1000?new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
lblTimeDis.setText(getTime());
}
});
tiTime.start();
}
public?String?getTime()?{
Calendar?c?=?Calendar.getInstance();
//?把時間轉換為習慣的時間
String?year?=?new?Integer(c.get(Calendar.YEAR)).toString();
String?month?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......??????5033??2008-12-09?08:46??名點程序\fr
????.......??????2027??2008-12-09?08:46??名點程序\SaveReadStu.java
????.......??????1119??2008-12-09?08:46??名點程序\SelectCall.java
????.......???????579??2008-12-09?08:46??名點程序\Students.java
?????目錄??????????0??2009-04-21?09:54??名點程序
-----------?---------??----------?-----??----
?????????????????8758????????????????????5
- 上一篇:java語言仿真CPU5級流水線源碼+報告
- 下一篇:java聊天室程序設計報告
評論
共有 條評論