zoukankan      html  css  js  c++  java
  • Swing图形用户界面

    package test;

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.*;

    public class chuangt extends JFrame {
    public chuangt(){
    //设置大小
    this.setSize(500,400);
    //设置标题
    this.setTitle("登录界面");
    //窗体的初始位置
    this.setLocationRelativeTo(null);//设置为null相对我的屏幕居中
    //设置窗体不可调整
    this.setResizable(false);
    //设置窗体自动关闭
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //设置窗体布局
    this.setLayout(null);//自由布局
    //添加控件类的实例
    JLabel jl =new JLabel("用户名:");
    jl.setBounds(100, 100, 70, 30);
    this.add(jl);
    JTextField jt =new JTextField();
    jt.setBounds(150, 100, 200, 30);
    this.add(jt);
    JLabel jl1 =new JLabel("密码:");
    jl1.setBounds(110, 150, 70, 30);
    this.add(jl1);
    JPasswordField jt1 =new JPasswordField();
    jt1.setBounds(150, 150, 200, 30);
    this.add(jt1);
    JButton btn=new JButton("注册");
    btn.setBounds(250, 250, 70, 30);
    this.add(btn);
    JButton btn1=new JButton("登录");
    btn1.setBounds(150, 250, 70, 30);
    btn1.addActionListener(new ActionListener(){

    @Override
    public void actionPerformed(ActionEvent e) {

    setVisible(false);
    cti2 ct =new cti2(chuangt.this);
    ct.setVisible(true);
    }

    });
    this.add(btn1);
    }
    public static void main(String args[]){
    chuangt ct=new chuangt();
    ct.setVisible(true);
    }

    }

  • 相关阅读:
    解决Eclipse中文乱码
    C++中set用法回顾
    二分查找题目汇总
    给网卡配置多个IP地址(win/linux)
    route在windows与liunx下的使用区别
    eclipse 编程 c++ 快捷键
    Git、GitHub、GitLab三者之间的联系以及区别
    SQL语句优化
    《领域驱动设计的原则与实践》读书笔记(一)
    DotNet Core 介绍
  • 原文地址:https://www.cnblogs.com/54ljj/p/5414421.html
Copyright © 2011-2022 走看看