标题:用户登录怎么弄
只看楼主
qq995354156
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2016-11-18
结帖率:100%
已结贴  问题点数:20 回复次数:4 
用户登录怎么弄
用box或Jpael怎么弄后面四个的

//BoxLayout:箱式布局,一般水平或垂直方向堆叠组件使用,特别是标签和文本框的组合最为常见
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.*;
import
import
import
import
import
import

import javax.swing.*;

public class BoxLayOutDemo extends JFrame {
    private JLabel userLabel;
    private JTextField userField;
    private JLabel passwordLabel;
    private JLabel Confirmpassword;
    private JPasswordField passwordField;
    private JPasswordField ConfirmpasswordField;
    private JButton login;
    private JButton cancel;
    private static String serverIP = "localhost";
    private static int PORT = 8000;
    private Socket socket;
    private ObjectOutputStream out;
    private ObjectInputStream in;

    public BoxLayOutDemo() {
        super("用户注册");
        userLabel = new JLabel("用户名:");
        userField = new JTextField(23);
        
        passwordLabel = new JLabel("密  码 :");
        passwordField = new JPasswordField(23);
        Confirmpassword = new JLabel("确认密 码:");
        ConfirmpasswordField = new JPasswordField(23);
        
        
        
        
        login = new JButton("登录");
        cancel = new JButton("取消");
        Box box1 = new Box(BoxLayout.X_AXIS);
        Box box2 = new Box(BoxLayout.X_AXIS);
        Box box3 = new Box(BoxLayout.X_AXIS);
        Box box5 = new Box(BoxLayout.X_AXIS);
        
        box1.add(userLabel);
        box1.add(userField);
        
        box2.add(passwordLabel);
        box2.add(passwordField);
        box3.add(Confirmpassword);
        box3.add(ConfirmpasswordField);
        
   
        
        box5.add(login);
        box5.add(cancel);
        
        Box box = new Box(BoxLayout.Y_AXIS);
        box.add(box1);
        box.add(box2);
        box.add(box3);
        box.add(comboBox);
        box.add(box5);
        Container c = getContentPane();
        c.add(box);
    }

    public static void main(String[] args) {
   
        BoxLayOutDemo login = new BoxLayOutDemo();
        BoxLayOutDemo cancel = new BoxLayOutDemo();
        login.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        login.pack();
        login.setVisible(true);
    }
}
搜索更多相关主题的帖子: 文本框 import public private 用户登录 
2017-05-13 21:35
zsh981022984
Rank: 3Rank: 3
来 自:湖南
等 级:论坛游侠
威 望:6
帖 子:36
专家分:153
注 册:2015-12-6
得分:0 
没看懂你要问什么....

因为有了因为,所以有了所以,既然已成既然,何必再说何必
2017-05-13 23:35
qq995354156
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2016-11-18
得分:0 
回复 2楼 zsh981022984
性别,爱好,地址,学历,这四个怎样做
2017-05-13 23:46
zsh981022984
Rank: 3Rank: 3
来 自:湖南
等 级:论坛游侠
威 望:6
帖 子:36
专家分:153
注 册:2015-12-6
得分:20 
回复 3楼 qq995354156
程序代码:
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.*;
import import import import import import import javax.swing.*;
import java.awt.*;

public class test extends JFrame {
    private JLabel userLabel;
    private JTextField userField;
    private JLabel passwordLabel;
    private JLabel Confirmpassword;
    private JPasswordField passwordField;
    private JPasswordField ConfirmpasswordField;
    private JButton login;
    private JButton cancel;
    private static String serverIP = "localhost";
    private static String[] Education={"高中或以下","本科","本科以上"};
    private static int PORT = 8000;
    private Socket socket;
    private ObjectOutputStream out;
    private ObjectInputStream in;

    public test() {
        super("用户注册");
        userLabel = new JLabel("用  户  名:");
        userField = new JTextField(23);
        passwordLabel = new JLabel("密         码:");
        passwordField = new JPasswordField(23);
        Confirmpassword = new JLabel("确认密码:");
        ConfirmpasswordField = new JPasswordField(23);
        
        JLabel jla1=new JLabel("性         别:");
        JLabel jla2=new JLabel("爱         好:");
        JLabel jla3=new JLabel("地         址:");
        JLabel jla4=new JLabel("学         历:");
        JRadioButton jrb1=new JRadioButton("男");
        JRadioButton jrb2=new JRadioButton("女");
        JCheckBox jck1=new JCheckBox("阅读");
        JCheckBox jck2=new JCheckBox("上网");
        JCheckBox jck3=new JCheckBox("游泳");
        JCheckBox jck4=new JCheckBox("旅行");
        JTextArea jta=new JTextArea(2,23);
        JComboBox<String>jcb=new JComboBox<String>(Education);
        
        
        login = new JButton("登录");
        cancel = new JButton("取消");
        Box box1 = new Box(BoxLayout.X_AXIS);
        Box box2 = new Box(BoxLayout.X_AXIS);
        Box box3 = new Box(BoxLayout.X_AXIS);
        Box box4 = new Box(BoxLayout.X_AXIS);
        Box box5 = new Box(BoxLayout.X_AXIS);
        Box box6 = new Box(BoxLayout.X_AXIS);
        Box box7 = new Box(BoxLayout.X_AXIS);
        Box box8 = new Box(BoxLayout.X_AXIS);
        
        box1.add(Box.createHorizontalStrut(5));
        box1.add(userLabel);
        box1.add(Box.createHorizontalStrut(10));
        box1.add(userField);
        box1.add(Box.createHorizontalStrut(10));
        
        box2.add(Box.createHorizontalStrut(5));
        box2.add(passwordLabel);
        box2.add(Box.createHorizontalStrut(10));
        box2.add(passwordField);
        box2.add(Box.createHorizontalStrut(10));
        
        box3.add(Box.createHorizontalStrut(5));
        box3.add(Confirmpassword);
        box3.add(Box.createHorizontalStrut(10));
        box3.add(ConfirmpasswordField);
        box3.add(Box.createHorizontalStrut(10));
        
        box4.add(Box.createHorizontalStrut(5));
        box4.add(jla1);
        box4.add(Box.createHorizontalStrut(5));
        box4.add(jrb1);
        box4.add(jrb2);
        box4.add(Box.createHorizontalStrut(360));
        
        box5.add(Box.createHorizontalStrut(5));
        box5.add(jla2);
        box5.add(Box.createHorizontalStrut(5));
        box5.add(jck1);
        box5.add(jck2);
        box5.add(jck3);
        box5.add(jck4);
        box5.add(Box.createHorizontalStrut(230));
        
        box6.add(Box.createHorizontalStrut(5));
        box6.add(jla3);
        box6.add(Box.createHorizontalStrut(10));
        box6.add(jta);
        box6.add(Box.createHorizontalStrut(10));
        
        box7.add(Box.createHorizontalStrut(5));
        box7.add(jla4);
        box7.add(Box.createHorizontalStrut(10));
        box7.add(jcb);
        box7.add(Box.createHorizontalStrut(80));
        
        box8.add(login);
        box8.add(cancel);
        
        Box box=new Box(BoxLayout.Y_AXIS);
        box.add(Box.createVerticalStrut(5));
        box.add(box1);
        box.add(Box.createVerticalStrut(15));
        box.add(box2);
        box.add(Box.createVerticalStrut(15));
        box.add(box3);
        box.add(Box.createVerticalStrut(15));
        box.add(box4);
        box.add(Box.createVerticalStrut(15));
        box.add(box5);
        box.add(Box.createVerticalStrut(15));
        box.add(box6);
        box.add(Box.createVerticalStrut(10));
        box.add(box7);
        box.add(Box.createVerticalStrut(15));
        box.add(box8);
        box.add(Box.createVerticalStrut(15));
        
        Container c = getContentPane();
        c.setSize(333,444);
        c.add(box);
    }

    public static void main(String[] args) {
    
        test login = new test();
        test cancel = new test();
        login.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        login.pack();
        login.setVisible(true);
    }
}

这是我做的,现学的,在这个 http://blog. 博客,你自己可以去看以下,没时间注释了。。。可能还有点问题,看以后能不能搞定

因为有了因为,所以有了所以,既然已成既然,何必再说何必
2017-05-14 22:30
qq995354156
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2016-11-18
得分:0 
回复 4楼 zsh981022984
谢谢
2017-05-14 23:07



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




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

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