想从登录的窗口跳转到注册的窗口,这样写点击注册为什么不跳转packageview;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;impor...
想从登录的窗口跳转到注册的窗口,这样写点击注册为什么不跳转
package view;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class View {
public static void main(String[] args) {
LoginView lv = new LoginView();
//lv.setLocationRelativeTo(null);
}
}
//登录窗口
class LoginView extends JFrame{
public static JButton butt_registe = new JButton("注册");
public LoginView()
{
setTitle("QQ2013 追梦——设计");
setLayout(new GridLayout(3,2));
setSize(400,240);
add(new JLabel("用户名"));
add(new JTextField());
add(new JLabel("密码"));
add(new JPasswordField());
add(new JButton("登录"));
add(butt_registe);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
/注册窗口
class RegistView extends JFrame{
public RegistView()
{
setTitle("QQ2013 注册");
setLayout(new GridLayout(4,2));
setSize(500,280);
add(new JLabel("用户名"));
add(new JTextField());
add(new JLabel("密码"));
add(new JPasswordField());
add(new JLabel("确认密码"));
add(new JPasswordField());
add(new JButton("确定"));
add(new JButton("退出"));
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
//这是我写的那个监听器的部分,求指点
class LoViewRegiste implements ActionListener{
public void actionPerformed(ActionEvent event)
{
if(event.getSource().equals(LoginView.butt_registe))
{
new RegistView();
}
}
}
展开