#java GUI radio button getText

25 messages · Page 1 of 1 (latest)

grim mountain
#

When I click on a button1, it will return button1 in a row, But i can't use button2,3,4 and 5

pale ravenBOT
#

Hey, @grim mountain!
Please remember to /close this post once your question has been answered!

grim mountain
#
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

celest ferry
#

Hey, can you please explain what is actually happened, and what you was expecting

grim mountain
#

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

formal sleet
#

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

grim mountain
#

what can I do so I can get the Button source and put it in the Action

#

in Main.row[4]

formal sleet
grim mountain
# grim mountain

I mean that the remove button will show in the Action column here in pic

formal sleet
#

Oh ok you want a remove button for each row

#

Looks like you need to implement a TableCellRenderer

#

@grim mountain