Jradiobutton and Jbutton

Asked

Viewed 52 times

0

Good afternoon, you guys! Gentlemen, I’m developing a small application, which is a file converter for personal use here at the company and I’m faced with a question that may sound dumb, but I haven’t found a satisfactory answer yet. I have the following screen:

inserir a descrição da imagem aqui

My question is the following: I put logs on these radios, for every time some of them run, it print a line with their respective name. Only that I want them to be executed ONLY when the "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 just put one

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

whether it will perform the same way when I click the button? Thanks in advance!

1 answer

2

Of course, the second way is the best way to use. If you only need to validate when the user clicks the button, you do not need to use the Radio Button.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.