I'm implementing a specialized version of JTextField and want to pack it into an own bean. The bean works pretty fine so far. Here's my question:
How can I detect when the JTextField is shown? So that I can init some graphical stuff everytime the fields are shown.
The ShowComponent event does not work for me. FocusGained and FocusLost works just fine.
Hope there's somebody who knows the solution to this.
Can you use the isShowing() method? http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#isShowing%28%29
While using a ComponentListener and doing stuff in its componentShown intuitively seems to be the way to go, it doesn't help: it fires when the component's visible property is changed. That property is true by default (even if not yet added to any container showing on the screen), and consequently nothing fired on showing ..
Instead, use an AncestorListener and do what's needed in its ancestorAdded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With