标题:图形界面设计,复选框的问题,帮忙看下,
取消只看楼主
gxq0013
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2013-1-20
结帖率:100%
 问题点数:0 回复次数:2 
图形界面设计,复选框的问题,帮忙看下,
import javax.swing.*;

   class MyFrame extends JFrame{
       JLabel lab1,lab2,lab3,lab4,lab5,lab6,lab7,lab8,lab9;
       JTextField tf1,tf2;
       JPasswordField pwf1,pwf2;
       JTextArea ta;
       JRadioButton rbtMale;
       JRadioButton rbtFemale;
       ButtonGroup grp;
       JComboBox cmbMonth;
       JCheckBox check;
      
       MyFrame(String s){
           super(s);
           setSize(320,400);
           setLocationRelativeTo(null);
           
           JPanel pan=new JPanel();
           setContentPane(pan);
           
           lab1=new JLabel("用户名:");
           tf1=new JTextField(20);
           lab2=new JLabel("密码:");
           pwf1=new JPasswordField(20);
           lab3=new JLabel("确认密码:");
           pwf2=new JPasswordField(20);
           lab4=new JLabel("个人简历:");
           ta=new JTextArea(10,20);
           
           lab5=new JLabel("性别");
           rbtMale=new JRadioButton("男");
           rbtFemale=new JRadioButton("女");
           grp=new ButtonGroup();
           grp.add(rbtMale);
           grp.add(rbtFemale);
           
           lab6=new JLabel("证件类型");
           String text[]={"身份证","护照","学生证","驾驶证","军官证","其他"};
           ......
           
           lab7=new JLabel("证件号码");
           tf2=new JTextField(20);
           
           lab8=new JLabel("同意服务条款:");
           check=new JCheckBox("我已经看过并同意使用协议");
           
           pan.add(lab1);
           pan.add(tf1);
           pan.add(lab2);
           pan.add(pwf1);
           pan.add(lab3);
           pan.add(pwf2);
           pan.add(lab4);
           pan.add(ta);
           pan.add(lab5);
           pan.add(rbtMale);
           pan.add(rbtFemale);
           pan.add(lab6);
           pan.add();
           pan.add(lab7);
           pan.add(tf2);
           pan.add(lab8);
           pan.add(check);
           }
       }
   }

public class TextFieldDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         MyFrame frm=new MyFrame("注册界面");
    }

}





   
           lab6=new JLabel("证件类型");
           String text[]={"身份证","护照","学生证","驾驶证","军官证","其他"};
           ......
这里,复选框该怎么写,求个全代码,百度的是写得什么setSelectedItem() 之类的,书上完全没有详写过,也就提下,所以不知道这个该怎么用,会的帮忙完善下,先谢了啊



搜索更多相关主题的帖子: 界面设计 图形 import super null 
2013-01-23 19:32
gxq0013
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2013-1-20
得分:0 
哦,对不起,是求组件框ComboBox的写法,不是复选框
2013-01-23 20:16
gxq0013
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2013-1-20
得分:0 
lab6=new JLabel("证件类型");
cmbMonth=new JComboBox();
String text[]={"身份证","护照","学生证","驾驶证","军官证","其他"};
for(int i=0;i<text.length;i++){
   cmbMonth.addItem(text[i]);
}            
2013-01-24 19:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-397419-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.621566 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved