标题:eclipse编写一个简单实用的登陆界面
只看楼主
rz250
Rank: 1
等 级:禁止访问
帖 子:4
专家分:0
注 册:2013-11-17
结帖率:0
 问题点数:0 回复次数:2 
eclipse编写一个简单实用的登陆界面
花了点时间写了一个简单的页面:

package test;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class UserInterface extends JFrame implements WindowListener{
    JFrame jf;
    JPanel jpan1,jpan2,jpan3;
    JLabel username,password,lspace;
    JTextField user,pass;
    JButton login,register;
   
    public void go(){
        
        jf=new JFrame("UserInterface");
        jf.setSize(350, 250);
        jf.setResizable(false);
        jf.setLayout(new GridLayout(6,1,0,5));
        jpan1=new JPanel();
        jpan2=new JPanel();
        jpan3=new JPanel();
        username=new JLabel("Username");
        password=new JLabel("Password");
        user=new JTextField(12);
        pass=new JTextField(12);
        login=new JButton("Login");
        register=new JButton("Register");
        
        jpan1.setSize(200, 50);
        jpan1.add(username);
        jpan1.add(user);
        
        jpan2.setSize(200, 50);
        jpan2.add(password);
        jpan2.add(pass);
        
        jpan3.setLayout(new FlowLayout(FlowLayout.CENTER,20,0));
        jpan3.add(login);
        jpan3.add(register);
        
        lspace=new JLabel();
        jf.add(lspace);
        jf.add(jpan1);
        jf.add(jpan2);
        lspace=new JLabel();
        jf.add(lspace);
        jf.add(jpan3);
        lspace=new JLabel();
        jf.add(lspace);
        
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        jf.setVisible(true);
    }
   
    public static void main(String[] args){
        
        UserInterface ui=new UserInterface();
        ui.go();
    }
   
    public void windowDeactivated(WindowEvent e){
        
    }

    @Override
    public void windowActivated(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowClosed(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowClosing(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowDeiconified(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowIconified(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowOpened(WindowEvent arg0) {
        // TODO Auto-generated method stub
        
    }

}


搜索更多相关主题的帖子: password register package public import 
2013-11-18 23:46
赵疯子
Rank: 8Rank: 8
来 自:dream
等 级:蝙蝠侠
威 望:2
帖 子:365
专家分:737
注 册:2013-5-5
得分:0 
楼主不觉得用JAVA写界面很麻烦吗?
2013-11-20 08:46
琢石成器
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:36
专家分:160
注 册:2013-11-10
得分:0 
我靠,你这不是我那天写的嘛,其实这段程序里面WindowListener这个接口显得多余了,就目前的界面来说,一点用处都没有,可以去掉。
2013-11-20 13:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-423769-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014777 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved