1、运用事件处理相关知识,完成两个窗口之间的切换,例如:登陆窗口------》注册窗口
2、对本次作业进行总结,在编程过程中遇到哪些问题,如何解决,有哪些收获?
package Laaaa; import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Dccc implements ActionListener { JFrame f1,f2; JPanel p1,p2; JButton b1,b2; JLabel l1,l2,l3; JTextField t1,t2;//文本框 public Dccc() { f1=new JFrame("LYX"); f2=new JFrame("LYX"); p1=new JPanel(); p2=new JPanel(); p1.setLayout(null);//流布局 p2.setLayout(null); b1=new JButton("注册"); b2=new JButton("登录"); l1=new JLabel("账户"); l1.setFont(new Font("楷体",Font.BOLD,18));//自定义标签字体 l2=new JLabel("密码"); l2.setFont(new Font("楷体",Font.BOLD,18)); l3=new JLabel("登录成功!"); l3.setForeground(Color.red); t1=new JTextField(); t2=new JTextField(); b1.addActionListener(this); b2.addActionListener(this); f1.add(p1); p1.add(b1); p1.add(b2); p1.add(l1); p1.add(l2); p1.add(t1); p1.add(t2); b1.setBounds(150,150,60,40); b2.setBounds(270,150,60,40); l1.setBounds(80,50,40,30); l2.setBounds(80,100,40,30); t1.setBounds(120,50,300,30); t2.setBounds(120,100,300,30); f1.setVisible(true); f1.setSize(500,300); } public static void main(String[] args) { new Dccc(); } public void actionPerformed(ActionEvent e) { f1.setVisible(false); p2.setBackground(new Color(211,252,4));//自定义面板颜色 f2.setVisible(true); f2.add(p2); p2.add(l3); l3.setBounds(225,75,150,60); f2.setLocation(600,0); f2.setSize(500,300); } }
本次上机很复杂,很难,我没有写完。。。