java登陆器_Java登陆器

主界面:importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JFrame;publicclassMainFrame{publicstaticvoidmain(String[]args){lauchFramelf...

主界面:

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JFrame;

public class MainFrame{

public static void main(String[] args){

lauchFrame lf = new lauchFrame();

}

}

class lauchFrame extends JFrame {

JFrame mainframe = new JFrame();

public lauchFrame(){

this.setTitle("IS");

this.setSize(800, 600);

this.setResizable(false);

this.setLocationRelativeTo(null);

this.setVisible(true);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

}

登陆界面:import java.awt.GridLayout;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.awt.event.WindowListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class logonWin extends JFrame {

public static void main(String[] args){

logonFrame lf = new logonFrame();

}

}

class logonFrame extends JFrame implements ActionListener{

static JFrame logon = new JFrame("Logon");

private JLabel lab1 = new JLabel();

private JLabel lab2 = new JLabel();

private JTextField tf = new JTextField();

private JPasswordField pf = new JPasswordField();

private JButton bt1 = new JButton();

private JButton bt2 = new JButton();

logonFrame(){

lab1.setBounds(new Rectangle(56, 26, 39, 18));

lab1.setText("用户名");

lab2.setBounds(new Rectangle(57, 59, 26, 18));

lab2.setText("密码");

tf.setBounds(new Rectangle(123, 25, 118, 22));

pf.setBounds(new Rectangle(123, 59, 118, 22));

bt1.setBounds(new Rectangle(57, 100, 60, 28));

bt1.setText("登陆");

bt1.addActionListener(this);

bt2.setBounds(new Rectangle(174, 100, 60, 28));

bt2.setText("退出");

bt2.addActionListener(this);

logon.setLayout(null);

logon.setSize(300, 200);

logon.add(lab1);

logon.add(tf);

logon.add(lab2);

logon.add(pf);

logon.add(bt1);

logon.add(bt2);

logon.setDefaultCloseOperation(EXIT_ON_CLOSE);

logon.setResizable(false);

logon.setLocationRelativeTo(null);

logon.setVisible(true);

}

public void actionPerformed(ActionEvent e) {

if (e.getSource() == bt2) {

System.exit(0);

}

if (e.getSource() == bt1) {

MainFrame mf = new MainFrame();

System.exit(0);

}

}

}

在登陆界面通过按键调用不了主界面,主界面单独运行时可以显示,请问是什么问题啊

是不是if (e.getSource() == bt1) {

MainFrame mf = new MainFrame();

System.exit(0);

}

的System.exit(0);的问题啊

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值