资源简介
用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聊天室程序设计报告
评论
共有 条评论