RadionButtons
(男性和女性)中获取所选项目时遇到了挑战。
RadioButton selected = genderGroup.getRadioButton(genderGroup.getSelectedIndex());
String selectedGender = selected.toString();
我尝试了上面的代码块,但从未达到我的预期。
有人请帮我一把。
此致 凯文。
答案 0 :(得分:3)
我想您要从RadioButton
中提取的内容是与此RadioButton
相关联的文字。为此,您需要使用getText()
代替toString()
。
这就是你想要做的吗?
答案 1 :(得分:1)
hey kevintich请使用本准则......
ComponentGroup radioGroup = new ComponentGroup();
final RadioButton defaultBorder = new RadioButton("Default");
radioGroup.addComponent(defaultBorder);
final RadioButton etchedBorder = new RadioButton("Etched Raised Theme");
radioGroup.addComponent(etchedBorder);
final RadioButton etchedColors = new RadioButton("Etched Raised Colors");
radioGroup.addComponent(etchedColors);
final RadioButton etchedLowBorder = new RadioButton("Etched Lowered Theme");
radioGroup.addComponent(etchedLowBorder);
final RadioButton etchedLowColors = new RadioButton("Etched Lowered Colors");
radioGroup.addComponent(etchedLowColors);
final RadioButton bevelBorder = new RadioButton("Bevel Raised Theme");
radioGroup.addComponent(bevelBorder);
final RadioButton bevelColors = new RadioButton("Bevel Raised Colors");
radioGroup.addComponent(bevelColors);
final RadioButton bevelLowBorder = new RadioButton("Bevel Lowered Theme");
radioGroup.addComponent(bevelLowBorder);
final RadioButton bevelLowColors = new RadioButton("Bevel Lowered Colors");
radioGroup.addComponent(bevelLowColors);
final RadioButton roundBorder = new RadioButton("Round Theme");
radioGroup.addComponent(roundBorder);
final RadioButton roundColors = new RadioButton("Round Colors");
radioGroup.addComponent(roundColors);
RadioButton disabledRadioButton = new RadioButton("Disabled Radio Button");
disabledRadioButton.setEnabled(false);
radioGroup.addComponent(disabledRadioButton);
f.addComponent(radioGroup);