java单选框和确定按钮_JAVA中怎样判断单选按钮和复选框是否选中

我做的简单程序(用jbuilder做的),大家帮我看看怎样才能在我点“提交”按钮时,获得单选按钮的值,和复选框的值packagehelloworld;importjava.awt.*;importjavax.swing.*;importcom...

我做的简单程序(用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);}}

展开

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页

打赏

weixin_39895881

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者