zoukankan      html  css  js  c++  java
  • swing之checkbox

    import java.awt.GridLayout;
    
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    
    public class danfu extends JFrame{
        JPanel jp1,jp2,jp3;
        JButton jb1,jb2;
        JLabel jl1,jl2;
        JCheckBox jc1,jc2,jc3;
        JRadioButton jr1,jr2;
        ButtonGroup bg;
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            danfu df=new danfu();
        }
    
        
        public danfu()
           {
            jp1=new JPanel();
            jp2=new JPanel();
            jp3=new JPanel();
            
            
            jb1=new JButton("注册");
            jb2=new JButton("取消");
            
            jl1=new JLabel("特长");
            jl2=new JLabel("性别");
            
            jc1=new JCheckBox("音乐");
            jc2=new JCheckBox("体育");
            jc3=new JCheckBox("文艺");
            
            jr1=new JRadioButton("");
            jr2=new JRadioButton("");
            
            bg=new ButtonGroup();//将单选按钮添加到组,使其只能选择一个
            bg.add(jr1);
            bg.add(jr2);
            
            jp1.add(jl1);
            jp1.add(jc1);
            jp1.add(jc2);
            jp1.add(jc3);
            
            jp2.add(jl2);
            jp2.add(jr1);
            jp2.add(jr2);
            
            jp3.add(jb1);
            jp3.add(jb2);
            
            
            this.setLayout(new GridLayout(3,1));
            this.add(jp1);
            this.add(jp2);
            this.add(jp3);
            
            this.setTitle("担心");
            this.setSize(400,320);
            this.setLocation(100, 180);
            this.setResizable(true);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setVisible(true);
            
            
            
           }
        
        
    }
  • 相关阅读:
    pycurl之公共方法--请求/上传/下载,解析json
    BAT启动关闭VMWARE的虚拟机
    LINUX免密登录SSH下的操作之自动COPY部署到其他机器
    python 可迭代对象
    python itertools 迭代器增加元素
    python django
    《Linux下mysql安装》
    linux下安装mysql
    hive基本语法
    linux连接工具MobaXterm下载及使用
  • 原文地址:https://www.cnblogs.com/luo-mao/p/6030481.html
Copyright © 2011-2022 走看看