#java GUI radio button getText
25 messages · Page 1 of 1 (latest)
Hey, @grim mountain!
Please remember to /close this post once your question has been answered!
Save.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
Main.row[0] = Restaurant.getText();
Main.row[1] = Reviewer.getText();
Main.row[2] = Review.getText();
Main.row[3] = Rate1.getText() // I want to use Rate2 to Rate5
Main.model.addRow(Main.row);
}
});```
in Main.row[3] I can only choose radioButton1
what can I do so I can use Rate1 to 5
I tried Main.row[3] = Rate2.getText(); but it will not work
can I use logical or || I tried something but I dunno
Hey, can you please explain what is actually happened, and what you was expecting
this is my output
I cant use button 2 3 4 and 5
The button 1 syntax is Rate1.getText()
I tried also Main.row[3] = group.getSelection().getActionCommand()); and it also doesn't work it gives blank number
and also how can I add button in Main.row[4] = buttonHere
That's because you only ever call Rate1.getText so it will only ever return 1
You should put the radio buttons in a ButtonGroup and call getSelection to get the selected rating
That will also solve other issues like making sure only one rating is selected at once etc
declaration: module: java.desktop, package: javax.swing, class: ButtonGroup
hello I ty I fixed the problem
what can I do so I can get the Button source and put it in the Action
in Main.row[4]
What do you mean by button source
I mean that the remove button will show in the Action column here in pic