用户注册界面设置
来源:互联网 发布:天刀捏脸数据女女神 编辑:程序博客网 时间:2024/05/16 16:22
import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JScrollBar;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;public class TestGridBagLayout extends JFrame{ //注册名和密码 JTextField userName=null; JPasswordField userPwd=null; JPasswordField userPwdSubmit=null; //性别 JRadioButton man=null; JRadioButton woman=null; //爱好 JCheckBox hobby1=null; JCheckBox hobby2=null; JCheckBox hobby3=null; //定义几个面板 JPanel jp1=null; JPanel jp2=null; JPanel jp3=null; JPanel jp4=null; //出生日期 JComboBox year=null; JComboBox month =null; JComboBox day=null; //个人简介 JTextArea intreduce=null; //提交按钮 JButton submit=null; JButton reset=null; ButtonGroup bg=null; TestGridBagLayout(){ //this.setBounds(20,20,50, 50); this.setSize(400,600); this.setTitle("注册用户界面"); this.setLocationRelativeTo(null); initComponent(); addComponent(); this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } private void addComponent() { //设置网格包布局 this.setLayout(new GridBagLayout()); GridBagConstraints gbc=new GridBagConstraints(); //用户名区域 gbc.gridx=0; gbc.gridy=0; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("用户名"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=0; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(userName,gbc); //设置密码区域 gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=1; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("密码"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=1; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(userPwd,gbc); //设置密码确认 gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=2; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("密码确认"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=2; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(userPwdSubmit,gbc); //设置性别位置 gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=3; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("性别"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=3; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(jp1,gbc); jp1.add(man); jp1.add(woman); bg.add(woman); bg.add(man); //设置爱好区域 gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=4; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("爱好"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=4; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(jp2,gbc); jp2.add(hobby1); jp2.add(hobby2); jp2.add(hobby3); //设置出生日期 gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=5; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("出生日期"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=5; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.WEST; this.add(jp3,gbc); jp3.add(year); jp3.add(new JLabel("年")); jp3.add(month); jp3.add(new JLabel("月")); jp3.add(day); jp3.add(new JLabel("日")); gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=6; gbc.weightx=1; gbc.weighty=1; gbc.anchor = GridBagConstraints.EAST; this.add(new JLabel("个人简介"),gbc); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=6; gbc.anchor = GridBagConstraints.WEST; this.add(intreduce,gbc); this.add(new JScrollPane(intreduce),gbc);// gbc=new GridBagConstraints();// gbc.gridx=0;// gbc.gridy=7;// gbc.weightx=1;// gbc.weighty=1;// this.add(jp4,gbc);// jp4.add(submit);// jp4.add(reset); gbc=new GridBagConstraints(); gbc.gridx=0; gbc.gridy=7; //gbc.anchor = GridBagConstraints.EAST; this.add(submit,gbc); // submit.addActionListener(my); // submit.setActionCommand(submit); gbc=new GridBagConstraints(); gbc.gridx=1; gbc.gridy=7; //gbc.anchor = GridBagConstraints.WEST; this.add(reset,gbc); // reset.addActionListener(my); // reset.setActionCommand(reset); } private void initComponent() { userName=new JTextField(10); userPwd=new JPasswordField(10); userPwdSubmit=new JPasswordField(10); jp1=new JPanel(); jp2=new JPanel(); jp3=new JPanel(); jp4=new JPanel(); man=new JRadioButton("男"); woman =new JRadioButton("女"); bg=new ButtonGroup(); hobby1 =new JCheckBox("足球"); hobby2 =new JCheckBox("篮球"); hobby3 =new JCheckBox("排球"); String []yearDate=new String[53]; for(int i=0;i<yearDate.length;i++){ yearDate[i]=(i+1960)+""; } year=new JComboBox(yearDate); String []monthDate=new String[12]; for(int i=0;i<monthDate.length;i++){ monthDate[i]=(i+1)+""; } month=new JComboBox(monthDate); String []dayDate=new String[31]; for(int i=0;i<dayDate.length;i++){ dayDate[i]=(i+1)+""; } day =new JComboBox(dayDate); intreduce=new JTextArea(12,15); submit=new JButton("确认"); reset=new JButton("重置"); } }-------------------------------------------------------------------------------------------------//主函数测试public class Test { public static void main(String []args){ new TestGridBagLayout(); }}
------------------------------------------------------------------------
做了好久只做好了界面,功能还没实现。。界面如下:
0 0
- 用户注册界面设置
- 简单用户注册界面
- android 用户注册界面
- 用户注册界面
- 用户注册登陆查询界面
- 仿写学编程用户注册界面
- 原生js用户注册界面
- HTML实现用户注册界面
- swing 实现用户注册界面
- Jenkins设置允许用户注册
- PHP+Ajax实现用户注册的界面
- (HTML)简单的用户注册界面
- Android 用户注册界面的实现
- form表单实现用户注册界面
- 带选择头像的用户注册界面
- Android代码练习:用户注册界面
- iOS 调用用户设置界面
- 用户登录界面的设置
- ICDE2013论文翻译草稿:CPU and Cache Efficient Management of Memory-Resident Databases
- 黑马程序员-关于异常的一些问题
- json
- 利用域控设置启动脚本统一更改客户端administrator密码和添加客户端本地管理员账号
- 设定JFreeChart柱子上面的颜色
- 用户注册界面设置
- 看unix高级编程时遇到apue.h找不到的问题
- windows sdk 实现文件拖拽 不是使用mfc
- ios自动释放池相关,autoreleasepool;
- 对c&c++源文件和头文件分开的好处的一点认识
- 第十五天【java虐我千百遍,我待java如初恋】
- 虚函数
- what is SOA Gateway
- 【CSDN常见问题解答】Swing监听组合键