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);}}
展开
2个回答
展开全部
没用过GUI,但是js中的有个checked属性,你可以参照一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
isSelected();返回true被选中,反之未选中;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询