0
我意識到這可能是noob問題的定義,但我相當卡住,非常感謝任何幫助。在單獨的類中獲取選定的單選按鈕的isSelected值
我有一個actionlistener
和JRadioButton
它在ValublesMain
這樣的類中聲明。
JRadioButton name = new JRadioButton("Name", true);
name.addActionListener(new NameListener());
NameListener
被進一步聲明爲這樣。
class NameListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
display.setText("");
for(Valuble item : valubles)
if(name.isSelected()){
//Bunch of code and stuff
}
}
}
我的問題是,名稱不可見,我不知道我在做什麼錯在這裏。我認爲NameListener能夠看到名字,因爲它是在這裏聲明的。
name.addActionListener(new NameListener());
我在這裏錯過了什麼?
這個問題解決了,非常感謝你的
JRadioButton
! – VICWICIV