窗口的切换
窗口的转接
package czy; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class frame implements ActionListener{ JFrame f1,f2; JPanel p1,p2; JButton b1,b2; JLabel l1,l2,l3,l4; JTextField t1,t2; JPasswordField s1,s2; frame(){ f1=new JFrame("登陆"); p1=new JPanel(); b1=new JButton("注册账号"); l1=new JLabel("账号:"); l2=new JLabel("密码:"); t1=new JTextField(18); s1=new JPasswordField(18); f1.add(p1); p1.add(l1); p1.add(t1); p1.add(l2); p1.add(s1); p1.add(b1); f1.setVisible(true); f1.setSize(280,150); b1.addActionListener(this); } public static void main(String[] args) { new newframe(); } @Override public void actionPerformed(ActionEvent e) { f2=new JFrame("注册"); p2=new JPanel(); b2=new JButton("注册"); l3=new JLabel("账号:"); l4=new JLabel("密码:"); t2=new JTextField(18); s2=new JPasswordField(18); f2.add(p2); p2.add(l3); p2.add(t2); p2.add(l4); p2.add(s2); p2.add(b2); f2.setVisible(true); f2.setSize(280,150); f1.dispose(); //关闭第一个窗口 p2.setBackground(Color.blue); } }
Exception in thread "main" java.lang.Error: Unresolved compilation problem: newframe cannot be resolved to a type
at czy.frame.main(frame.java:37)