亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

java swing JRadioButton如何獲取值

java swing JRadioButton如何獲取值

TerryLau 2016-06-16 11:23:08
多個JRadioButton 加入ButtonGroup之后,如何獲取某個選定的JRadioButton 的值。我試過好多辦法都不行,以下是部分代碼:????????????????JRadioButton rbtnUser = new JRadioButton("普通用戶",true); //default select rbtnUser.setBounds(129, 175, 87, 23); contentPane.add(rbtnUser); JRadioButton rbtnRoot = new JRadioButton("管理員"); rbtnRoot.setBounds(225, 175, 64, 23); contentPane.add(rbtnRoot); ButtonGroup bg=new ButtonGroup(); bg.add(rbtnUser); bg.add(rbtnRoot); if(rbtnUser.isSelected()){ userType=rbtnUser.getText(); }else if(rbtnRoot.isSelected()){ userType=rbtnRoot.getText(); }????????為什么每次只能獲得默認選擇的“普通用戶”的值,另一個無法獲取。。。。。????????各路大神幫幫忙,趕著交作業呢。。。。。謝謝
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 4970 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號