首页 > 代码库 > 用户各种按钮
用户各种按钮
1 package Layout; 2 import java.awt.*; 3 import javax.swing.*; 4 5 public class UserLogin extends JFrame { 6 private JPanel p1 =new JPanel(); //面板 7 private JPanel p2 =new JPanel();//new FlowLayout(FlowLayout.LEFT) 8 private JPanel p3 =new JPanel(); 9 private JPanel p4 =new JPanel(); 10 private JPanel p5 =new JPanel(); 11 private JPanel p6 =new JPanel(); 12 private JPanel p7 =new JPanel(); 13 private JButton b1 = new JButton("登录"); 14 private JButton b2 = new JButton("取消"); 15 private JCheckBox c1 = new JCheckBox("音乐");//复选按钮 16 private JCheckBox c2 = new JCheckBox("体育"); 17 private JCheckBox c3 = new JCheckBox("美术"); 18 private JRadioButton r1 = new JRadioButton("男"); //单选按钮 19 private JRadioButton r2 = new JRadioButton("女"); 20 private ButtonGroup g1 = new ButtonGroup(); 21 private ButtonGroup g2 = new ButtonGroup(); 22 private JLabel l1 = new JLabel("用户名");//标签 23 private JLabel l2 = new JLabel("密 码"); 24 private JLabel l3 = new JLabel("特 长"); 25 private JLabel l4 = new JLabel("性 别"); 26 private JTextField t = new JTextField(10);//文本框 27 private JPasswordField w = new JPasswordField(10); //密码框 28 private String str1[] = {"北京","上海","天津","重庆"}; 29 private String str2[] = {"1","2","3","4"}; 30 private JComboBox xlk = new JComboBox(str1); //下拉框 31 private JList lb = new JList(str2); //列表 32 private JScrollPane gd = new JScrollPane(lb); //滚动条 33 public UserLogin (){ 34 35 this.setLayout(new GridLayout(7,2)); //网格布局管理器 36 g1.add(c1); g1.add(c2); g1.add(c3); 37 g2.add(r1); g2.add(r2); 38 p1.add(l1); p1.add(t); 39 p2.add(l2); p2.add(w); 40 p3.add(l3); p3.add(c1); p3.add(c2); p3.add(c3); 41 p4.add(l4); p4.add(r1); p4.add(r2); 42 p5.add(b1); p5.add(b2); 43 p6.add(xlk); 44 lb.setVisibleRowCount(3); //滚动条 45 p7.add(gd); 46 this.add(p1); 47 this.add(p2); 48 this.add(p3); 49 this.add(p4); 50 this.add(p5); 51 this.add(p6); 52 this.add(p7); 53 this.setTitle("用户登录"); 54 this.setSize(500,400); 55 // this.setResizable(false); //是否允许·更改大小 56 this.setLocation(1,1); 57 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 58 // this.pack(); 59 this.setVisible(true); 60 61 } 62 public static void main(String[] args) { 63 UserLogin l = new UserLogin(); 64 65 } 66 67 }
用户各种按钮
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。