import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import javax.swing.*;
public class qiandao extends JFrame implements MouseListener{
JPanel jp1=new JPanel();
JPanel jp2=new JPanel();
JPanel jp3=new JPanel();
JPanel jp4=new JPanel();
File f=new File("d://考勤名单.txt");
String s=new String();
Writer w=null;
//JTextField jtx1=new JTextField(5);
JLabel jl1=new JLabel(" 学号");
JTextField jtx2=new JTextField(1);
JLabel jl2=new JLabel(" 姓名");
JTextField jtx3=new JTextField(1);
JButton jb1=new JButton("提交");
JRadioButton jrb1=new JRadioButton("已到");
JRadioButton jrb2=new JRadioButton("未到");
ButtonGroup g=new ButtonGroup();
public static void main(String[] args) {
// TODO Auto-generated method stub
qiandao d=new qiandao();
}
public qiandao(){
//jtx1.setSize(50, 5);
//jp1.add(jtx1);
jp2.add(jl1);
jp2.add(jtx2);
jp2.add(jl2);
jp2.add(jtx3);
g.add(jrb1);
g.add(jrb2);
jp3.add(jrb1);
jp3.add(jrb2);
jp4.add(jb1);
jb1.addMouseListener(this);
jp2.setLayout(new GridLayout(2,2));
this.setLayout(new GridLayout(4,1));
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(250, 200);
this.setResizable(false);
this.setVisible(true);
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
String s1=new String();
String s2=new String();
String s3=new String();
s1=jtx2.getText();
s2=jtx3.getText();
if(jrb1.isSelected()){
s3="已到";
}else s3="未到";
s=s1+","+s2+","+s3;
try {
w=new FileWriter(f);
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
w.write(s+"\r\n");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
w.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import javax.swing.*;
public class qiandao extends JFrame implements MouseListener{
JPanel jp1=new JPanel();
JPanel jp2=new JPanel();
JPanel jp3=new JPanel();
JPanel jp4=new JPanel();
File f=new File("d://考勤名单.txt");
String s=new String();
Writer w=null;
//JTextField jtx1=new JTextField(5);
JLabel jl1=new JLabel(" 学号");
JTextField jtx2=new JTextField(1);
JLabel jl2=new JLabel(" 姓名");
JTextField jtx3=new JTextField(1);
JButton jb1=new JButton("提交");
JRadioButton jrb1=new JRadioButton("已到");
JRadioButton jrb2=new JRadioButton("未到");
ButtonGroup g=new ButtonGroup();
public static void main(String[] args) {
// TODO Auto-generated method stub
qiandao d=new qiandao();
}
public qiandao(){
//jtx1.setSize(50, 5);
//jp1.add(jtx1);
jp2.add(jl1);
jp2.add(jtx2);
jp2.add(jl2);
jp2.add(jtx3);
g.add(jrb1);
g.add(jrb2);
jp3.add(jrb1);
jp3.add(jrb2);
jp4.add(jb1);
jb1.addMouseListener(this);
jp2.setLayout(new GridLayout(2,2));
this.setLayout(new GridLayout(4,1));
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(250, 200);
this.setResizable(false);
this.setVisible(true);
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
String s1=new String();
String s2=new String();
String s3=new String();
s1=jtx2.getText();
s2=jtx3.getText();
if(jrb1.isSelected()){
s3="已到";
}else s3="未到";
s=s1+","+s2+","+s3;
try {
w=new FileWriter(f);
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
w.write(s+"\r\n");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
w.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}