Java中复选框CheckBox的使用
4个回答
2013-08-11
展开全部
import java.awt. *; import java.awt.event. *;import java.applet. *;public class CheckBoxDemo extends Applet implements ItenListener {String msg=" ";CheckBox WinXP,winNT,solaris,mac;public void init(){WinXP=new CheckBox("WindowsXP",null,true);winNT=new Checkbox("Window NT/2000");solaris=new Checkbox("Solaris");mac=new CheckBox("MacOS");add(WinXP);add(WinNT);add(solaris);add(mac);WinXP.addItemListener(this);winNT.addItenListener(this);solaris.addItenListener(this);mac.addItenListener(this);}public v oid itemStateChanged(ItemEvent ie){repaint();}public void paint(Graphics g)msg="当前系统是:";g.drawString(msg,6,80);msg="Windows XP:"+WinXP.getState();g.drawString(msg,6,100);msg="Windows NT/2000:"+WinNT.getState();
g.drawString(msg,6,120);msg="Solaris :"+WinXP.getState();g.drawString(msg,6,140);msg="MacOS :"+mac.getState();g.drawString(msg,6,160); }}
g.drawString(msg,6,120);msg="Solaris :"+WinXP.getState();g.drawString(msg,6,140);msg="MacOS :"+mac.getState();g.drawString(msg,6,160); }}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-11
展开全部
<input type="checkbox" name="cbx" value="v1"><input type="checkbox" name="cbx" value="v2">当提交后用request。getParaments(“cbx”);就能取到数组。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.*;
import java.awt.Color;
import java.awt.*;
public class Qualification extends Frame {
Label lb1 = new Label("您的学历为:");
CheckboxGroup cg = new CheckboxGroup();
Checkbox r1 = new Checkbox("专科", cg, false);
Checkbox r2 = new Checkbox("本科", cg, false);
Checkbox r3 = new Checkbox("硕士", cg, false);
Checkbox r4 = new Checkbox("博士", cg, true);
Label lb2 = new Label("您精通的语言为:");
Checkbox t1 = new Checkbox("Visual Basic");
Checkbox t2 = new Checkbox("Visual C++");
Checkbox t3 = new Checkbox("Java");
public Qualification(String s) {
super(s);
setLayout(new GridLayout(10, 1));
add(lb1);
add(r1);
add(r2);
add(r3);
add(r4);
add(lb2);
add(t1);
add(t2);
add(t3);
}
public static void main(String args[]) {
Qualification q = new Qualification("学识!");
q.setSize(400, 250);
q.setLocation(200, 300);
q.setVisible(true);
}
}
import java.awt.Color;
import java.awt.*;
public class Qualification extends Frame {
Label lb1 = new Label("您的学历为:");
CheckboxGroup cg = new CheckboxGroup();
Checkbox r1 = new Checkbox("专科", cg, false);
Checkbox r2 = new Checkbox("本科", cg, false);
Checkbox r3 = new Checkbox("硕士", cg, false);
Checkbox r4 = new Checkbox("博士", cg, true);
Label lb2 = new Label("您精通的语言为:");
Checkbox t1 = new Checkbox("Visual Basic");
Checkbox t2 = new Checkbox("Visual C++");
Checkbox t3 = new Checkbox("Java");
public Qualification(String s) {
super(s);
setLayout(new GridLayout(10, 1));
add(lb1);
add(r1);
add(r2);
add(r3);
add(r4);
add(lb2);
add(t1);
add(t2);
add(t3);
}
public static void main(String args[]) {
Qualification q = new Qualification("学识!");
q.setSize(400, 250);
q.setLocation(200, 300);
q.setVisible(true);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询