zoukankan      html  css  js  c++  java
  • java简单界面实现

    import javax.swing.JFrame;
    import javax.swing.JPanel;
    
    public class DemoFrame extends JFrame{
    		public DemoFrame(DemoPanel panel)
    		{
    			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    			this.setSize(300, 200);
    			this.setTitle("Frame Demo");
    			this.add(panel);
    			this.setResizable(false);
    			this.setVisible(true);
    		}
    		
    		public static void main(String[] args)
    		{
    			DemoPanel panel = new DemoPanel();
    			DemoFrame Frame = new DemoFrame(panel);
    		}
    }  

    import java.awt.GridLayout;
    
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    
    public class DemoPanel extends JPanel{
    
    	private JLabel labelUser, labelPassWd;            //标签      用户名,密码
    	private JButton buttonLogin, buttonReset;         //按钮      登录,重置
    	private JTextField textFieldUserName;             //文本框  用户名输入 
    	private JPasswordField passWdField;               //密码框  密码输入
        private JPanel panelUserName;
        private JPanel panelPassWd;
        private JPanel panelLoginButton;
    	
        public DemoPanel(){
        	this.labelUser = new JLabel("用户名");
        	this.labelPassWd = new JLabel("密    码");
        	this.buttonLogin = new JButton("登录");
        	this.buttonReset = new JButton("重置");
        	this.textFieldUserName = new JTextField(10);
        	this.passWdField = new JPasswordField(10);
        	this.panelPassWd = new JPanel();
        	this.panelUserName = new JPanel();
        	this.panelLoginButton = new JPanel();
        	
        	this.setLayout(new GridLayout(3, 1));  //网格式布局
        	
        	this.panelUserName.add(this.labelUser);
        	this.panelUserName.add(this.textFieldUserName);
        	this.panelPassWd.add(this.labelPassWd);
        	this.panelPassWd.add(this.passWdField);
        	this.panelLoginButton.add(buttonLogin);
        	this.panelLoginButton.add(buttonReset);
        	
        	this.add(this.panelUserName);
        	this.add(this.panelPassWd);
        	this.add(this.panelLoginButton);
        }
    }
    

    swing简单界面实现,运行结果如下:


  • 相关阅读:
    一个简易的MySQL性能查询脚本
    pt-osc原理、限制、及与原生online-ddl比较
    Netstat Commands for Linux Network Management
    MySQL 资源大全中文版
    自增表死锁问题分析及处理
    MySQL自带的性能压力测试工具mysqlslap
    iOS in-app purchase详解
    iOS 将Excel导入到SQLite3的过程
    iOS iTuns Connect官方配置教程
    OpenGL 知识二
  • 原文地址:https://www.cnblogs.com/fangyan5218/p/10618264.html
Copyright © 2011-2022 走看看