zoukankan      html  css  js  c++  java
  • 窗口的切换

    1、运用事件处理相关知识,完成两个窗口之间的切换,例如:登陆窗口------》注册窗口
    package qwe;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Ewq implements ActionListener {
    JFrame f1,f2;
    JPanel p1,p2;
    JLabel l1,l2,l3,l4;
    JButton b1,b2,b3;
    JTextField t1,t2,t3,t4;
    public Ewq(){
    f1 = new JFrame("登录");
    f2 = new JFrame("注册");
    p1 = new JPanel();
    p2 = new JPanel();
    l1 = new JLabel("账号:");
    l2 = new JLabel("密码:");
    l3 = new JLabel("用户名:");
    l4 = new JLabel("密码:");
    b1 = new JButton("登录");
    b2 = new JButton("注册");
    b3 = new JButton("注册成功");
    t1 = new JTextField(20);
    t2 = new JTextField(20);
    t3 = new JTextField(20);
    t4 = new JTextField(20);
    f1.add(p1);
    p1.add(l1);
    p1.add(t1);
    p1.add(l2);
    p1.add(t2);
    p1.add(b1);
    p1.add(b2);
    b2.addActionListener(this);
    f1.setVisible(true);
    f1.setSize(300, 200);
    f2.add(p2);
    p2.add(l3);
    p2.add(t3);
    p2.add(l4);
    p2.add(t4);
    p2.add(b3);
    f2.setVisible(false);
    }
    public static void main(String[] args) {
    new Ewq();
    }
    public void actionPerformed(ActionEvent e) {
    f1.setVisible(false);
    f2.setSize(300, 200);
    f2.setVisible(true);
    }

    }

  • 相关阅读:
    灾难 BZOJ 2815
    消耗战 BZOJ 2286
    征途 BZOJ 4518
    纸箱堆叠 BZOJ 2253
    Gate Of Babylon BZOJ 1272
    std::string::npos mean
    [转]整理索引碎片,提升SQL Server速度
    笔记本win7制作wifi
    关闭linux下的使用的端口
    linux多线程
  • 原文地址:https://www.cnblogs.com/6825186a/p/10884585.html
Copyright © 2011-2022 走看看