setEnabled « Button « Java Swing Q&A





1. JButton setEnabled    java-forums.org

Hi all, Just wondering, in the context of a JButton, what would setEnabled(false); do? I'm looking at someone else's code and they have a setEnabled(false) call inside the button actionlistener, this causes some very weird behaviour, namely apart from normal code, it somehow calls another component's focusgained and focuslost methods. Commenting it out makes everything work fine (it would seem). So ...

2. setting JButton setEnabled() outside of main class    java-forums.org

Hm, looking again at your post, do you have two same-named variables that hold similar instances of the JButton? If so, making changes to the non-displayed JButton will of course have no effect on the displayed one. I think you may think that by extending a call you have control over variables in other instances of the class, and this simply ...