• 选项框


    一、代码如下

    package www.tainiu.gui;
    
    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 ac__XuanXiangKuang__V1 extends JFrame {
    	JPanel jp1,jp2,jp3;
    	JLabel jl1,jl2;
    	JButton jb1,jb2;
    	JCheckBox jcb1,jcb2,jcb3;
    	JRadioButton jrb1,jrb2;
    	ButtonGroup by;
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		ac__XuanXiangKuang__V1 xv= new ac__XuanXiangKuang__V1();
    
    	}
    	
    	public ac__XuanXiangKuang__V1() {
    		// TODO Auto-generated constructor stub
    		//创建组件
    		this.jp1= new JPanel();
    		this.jp2= new JPanel();
    		this.jp3= new JPanel();
    		this.jl1= new JLabel("你喜欢的运动");
    		this.jl2= new JLabel("你的性别");
    		this.jb1= new JButton("注册用户");
    		this.jb2= new JButton("取消注册");
    		this.jcb1= new JCheckBox("足球");
    		this.jcb2= new JCheckBox("篮球");
    		this.jcb3= new JCheckBox("网球");
    		
    		this.jrb1= new JRadioButton("男");
    		this.jrb2= new JRadioButton("女");
    		ButtonGroup bg= new ButtonGroup();
    		bg.add(jb1);
    		bg.add(jb1);
    		
    		//设置管理器
    		this.setLayout(new GridLayout(3, 1));
    		//添加组件
    		this.jp1.add(this.jl1);
    		this.jp1.add(this.jcb1);
    		this.jp1.add(this.jcb2);
    		this.jp1.add(this.jcb3);
    		
    		this.jp2.add(this.jl2);
    		this.jp2.add(this.jrb1);
    		this.jp2.add(this.jrb2);
    		
    		this.jp3.add(jb1);
    		this.jp3.add(jb2);
    		
    		
    		this.add(this.jp1);
    		this.add(this.jp2);
    		this.add(this.jp3);
    		
    		//设置容器属性
    		this.setSize(300, 150);
    		this.setLocation(200, 200);
    		//this.setResizable(false);
    		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    		this.setVisible(true);
    		
    	}
    	
    	
    
    }
    
  • 相关阅读:
    centOS操作磁盘(命令行)
    TCP学习记录
    公务员考试考什么
    从动物科学到乐队鼓手,腾讯技术小哥的开源人生
    HarmonyOS实战—实现相亲APP
    oracle 以某个字符拆分成多行
    微信小程序预览 word、excel、ppt、pdf 等文件
    微信小程序相关问题排查技巧
    html 保留空格
    (转载)currentColor 让 CSS 更简短
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7553706.html
Copyright © 2020-2023  润新知