java GUI 性别单选框 日期选择框

/***************/
		/* 性别单选框 */
		sex = new JLabel("性	    别");
		sex.setBounds(20, 105, 105, 30);
		man = new JRadioButton("男");
		man.setSelected(true);
		woman = new JRadioButton("女");
		man.setBounds(128, 105, 75, 25);
		woman.setBounds(208, 105, 75, 25);
		ButtonGroup sexgrip = new ButtonGroup();// 设置性别组,保证只能选一个
		sexgrip.add(man);
		sexgrip.add(woman);
		this.add(sex);
		this.add(man);
		this.add(woman);

 

JComboBox year1, mon1, day1,year2, mon2, day2,hour1,hour2,minute1,minute2,second1,second2;

JLabel beg_time,end_time;

/************************/
	/** 开始时间设置 **/
	beg_time = new JLabel("开始日期");
	beg_time.setBounds(20, 100, 105, 30);
	this.add(beg_time);
	/* 年下拉框 */
	Vector<String> yy = new Vector<String>();
	for (int i = 1990; i <= 2019; i++) {
		yy.add(Integer.toString(i));
	}
	year1 = new JComboBox(yy);
	year1.setBounds(120, 105, 51, 20);
	year1.setBorder(null);// 设置无边框
	year1.setEditable(true);// 设置下拉框可编辑
	this.add(year1);
	/*******************/
	/* 月下拉框 */
	Vector<String> mm = new Vector<String>();
	for (int i = 1; i <= 12; i++) {
		String s1 = "";
		if (i < 10) {
			s1 = '0' + Integer.toString(i);
		} else {
			s1 = Integer.toString(i);
		}
		mm.add(s1);
	}
	mon1 = new JComboBox(mm);
	mon1.setBounds(171, 105, 40, 20);
	mon1.setBorder(null);// 设置无边框
	mon1.setEditable(true);// 设置下拉框可编辑
	this.add(mon1);
	/*****************/

	/* 日下拉框 */
	Vector<String> dd = new Vector<String>();
	for (int i = 1; i <= 31; i++) {
		String s1 = "";
		if (i < 10) {
			s1 = '0' + Integer.toString(i);
		} else {
			s1 = Integer.toString(i);
		}
		dd.add(s1);
	}
	day1 = new JComboBox(dd);
	day1.setBounds(211, 105, 40, 20);
	day1.setBorder(null);// 设置无边框
	day1.setEditable(true);// 设置下拉框可编辑
	this.add(day1);

效果显示

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章