Disable the last JButton pressed by pressing another and so on

-2

I'm creating a java interface with swing. The theme is the following, I have 9 Jbuttons and a textfield, every time I press a button, a different text appears, something simple. Well you see, I can not find the way to do that every time I press a new button, the previous button that I pressed is disabled definitively, so on. Does someone give me a hand? Thanks in advance ^^

    
asked by Aridai Francés 20.11.2018 в 22:58
source

1 answer

0

At the moment I managed to do what I wanted with this code, although its mission is not that, since as the fellow has told me jachguate, when I do tab between buttons they also block, and it is not desired, so I accept suggestions ^^, a greeting.

    JButton button_4 = new JButton("5");
    button_4.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            button_4.setEnabled(false);
        }
    });
    
answered by 20.11.2018 в 23:25