JRadioButton and JButton

0

Good afternoon everyone! Gentlemen, I'm developing a small application, which is a file converter for your own use here in the company and I come across a doubt that may seem stupid, but I have not found a satisfactory answer yet. It is as follows: I have the following little screen:

Myquestionisthis:Iputlogsontheseradios,everytimesomeofthemrun,itprintsalinewithitsname.OnlyIwantthemtorunONLYwhenthe"Start" button is pressed. My question is, for this to happen, I have to call the method

radioApagarInicioLinha.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //codigo aqui
        }
    });

Or if I simply put one

if (radioApagarInicioLinha.isSelected() == true) {
    System.out.println("Clicou!");
}

If it will perform the same way when I click the button? Thank you!

    
asked by anonymous 09.12.2015 / 19:05

1 answer

2

Sure enough, the second way is the best way to use it. If you just need to validate when the user clicks the button, you do not need to use the Radio Button event.

    
09.12.2015 / 19:07