日期:2014-05-20 浏览次数:20785 次
import java.awt.Button; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.Label; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Image1 { public void init1(){ Frame f =new Frame("学生考评系统"); Button b1=new Button("教师"); Button b2=new Button("学生"); Button b3=new Button("退出"); b2.addActionListener((ActionListener) new StudentListener()); Label l=new Label("欢迎来到学生考评系统,请选择用户"); f.setLayout(new FlowLayout(FlowLayout.LEFT,20,5)); f.add(l); f.add(b1); f.add(b2); f.add(b3); f.setBounds(470,230,250,120); f.pack(); f.setVisible(true); } class StudentListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { new Image2().init2(); } } class Image2 { public void init2() { Frame f=new Frame("学生用户"); Label l=new Label("请输入学号"); TextArea t=new TextArea(); f.setLayout(new FlowLayout(FlowLayout.LEFT,20,5)); f.add(l); f.add(t); f.pack(); } } public static void main(String[] args) { new Image1().init1(); } }