• 选项框


    一、代码如下

    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);
    		
    	}
    	
    	
    
    }
    
  • 相关阅读:
    JSP -java service pages
    java去重(1通过迭代器,2直接赋值)
    android 设置TextView水平滚动和解决首行缩进问题
    java 中字符串比较equals()和equalsIgnoreCase()的区别
    cursor的moveToNext()与moveToFirst()
    android studio快捷键
    android Android SDK Manager遇到的问题
    android onSaveInstanceState应用实例
    ProgressDialog的使用及逻辑处理
    POJ 1986 Distance Queries 【输入YY && LCA(Tarjan离线)】
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7553706.html
Copyright © 2020-2023  润新知