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);}}
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询