JAVA中怎样判断单选按钮和复选框是否选中

我做的简单程序(用jbuilder做的),大家帮我看看怎样才能在我点“提交”按钮时,获得单选按钮的值,和复选框的值packagehelloworld;importjava... 我做的简单程序(用jbuilder做的),大家帮我看看怎样才能在我点“提交”按钮时,获得单选按钮的值,和复选框的值package helloworld;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.XYLayout;import com.borland.jbcl.layout.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class Frame1 extends JFrame {XYLayout xYLayout1 = new XYLayout();JLabel jLabel1 = new JLabel();JRadioButton jRadioButton1 = new JRadioButton();JRadioButton jRadioButton2 = new JRadioButton();JButton jButton1 = new JButton();public Frame1() {try {jbInit();} catch (Exception exception) {exception.printStackTrace();}}private void jbInit() throws Exception {getContentPane().setLayout(xYLayout1);jLabel1.setText("性 别:");xYLayout1.setWidth(326);xYLayout1.setHeight(214);jButton1.setText("提 交");jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));jRadioButton2.setText("女");this.getContentPane().add(jButton1, new XYConstraints(124, 135, -1, -1));this.getContentPane().add(jLabel1, new XYConstraints(49, 60, 46, 21));this.getContentPane().add(jRadioButton1,new XYConstraints(127, 60, -1, -1));this.getContentPane().add(jRadioButton2,new XYConstraints(216, 60, -1, -1));jRadioButton1.setText("男");}public void jButton1_actionPerformed(ActionEvent e) {}}class Frame1_jButton1_actionAdapter implements ActionListener {private Frame1 adaptee;Frame1_jButton1_actionAdapter(Frame1 adaptee) {this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton1_actionPerformed(e);}} 展开
 我来答
xiangzaipiaobo
2012-04-09
知道答主
回答量:4
采纳率:0%
帮助的人:3.1万
展开全部
没用过GUI,但是js中的有个checked属性,你可以参照一下
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
yinyue_yymusic
2012-04-10 · TA获得超过156个赞
知道答主
回答量:178
采纳率:0%
帮助的人:71.7万
展开全部
isSelected();返回true被选中,反之未选中;
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式