| Author |
How to expose processFocusEvent when JFormattedTextField is already opened?
|
Jacky Luk
Ranch Hand
Joined: Aug 02, 2012
Posts: 201
|
|
I am using the Netbeans IDE, the JFormattedTextfield has been already created in the method called initComponents();
Therefore I cannot change it. I want to expose and override the method called processFocusEvent.
Any ideas I can do this after the control is created by the IDE wizard.
Thanks
Jack
|
 |
Jacky Luk
Ranch Hand
Joined: Aug 02, 2012
Posts: 201
|
|
Jacky Luk wrote:I am using the Netbeans IDE, the JFormattedTextfield has been already created in the method called initComponents();
Therefore I cannot change it. I want to expose and override the method called processFocusEvent.
Any ideas I can do this after the control is created by the IDE wizard.
Thanks
Jack
Anyone?
Thanks
Jack
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
|
Stop using the IDE wizard.
|
 |
Jacky Luk
Ranch Hand
Joined: Aug 02, 2012
Posts: 201
|
|
Campbell Ritchie wrote:Stop using the IDE wizard.
But I have invested in it a lot and it needs a great deal of work to restart again which I don't really want.
Are there any alternatives?
Thanks
Jack
|
 |
Tony Docherty
Bartender
Joined: Aug 07, 2007
Posts: 1225
|
|
I've never used the GUI wizard so don't know what features it has but one of the following may work:
1. Find a wizard feature that allows you to specify a method(s) in the the component to override.
2. Create you own component by extending JFormattedTextfield and override the method(s) you want to. Then add this custom component via the wizard.
3. Edit the code generated by the wizard. Note the generated code is probably hard to read and once edited you won't be able to use the wizard again so try to avoid this option.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
|
The problem with option 3 is that once you have used the wizard it may come back and return the code to its original state, so all your edits go walkies.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Tony Docherty wrote:1. Find a wizard feature that allows you to specify a method(s) in the the component to override.
Right-click -> Customize code -> select Custom creation
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
Brilliant, Darryl
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Campbell Ritchie wrote:Brilliant, Darryl 
Not really. Custom creation code has been available at least since NetBeans 5.5, the first version I used. And since I too started with the misconception that a visual designer could make things easier, I searched around and discovered the provision the first time I needed to override paintComponent(...).
I still maintain that learning to use the visual designer effectively is only worthwhile for those who plan to make GUI design their career. For the rest of us, it's more trouble than it's worth.
|
 |
Jacky Luk
Ranch Hand
Joined: Aug 02, 2012
Posts: 201
|
|
Now I am getting some wield behavior,
Custom component
Event Handler
I found that it is now okay to accept blanks, but if CheckDate returns false to it, it doesn't revert.
Secondly
This method doesn't throw at all when the input is 20/20/1992?!
Any suggestions?
Thanks
Jack
|
 |
Jacky Luk
Ranch Hand
Joined: Aug 02, 2012
Posts: 201
|
|
Any ideas?
Thanks
Jack
|
 |
Tony Docherty
Bartender
Joined: Aug 07, 2007
Posts: 1225
|
|
Any ideas?
Please EaseUp. We give our time and experience for free and don't want to feel pressurised into answering questions.
Never check a boolean value == true or false. For true you don't need to do anything and for false append '!' (NOT). Also doesn't getText() return a String, if so you don't need to call toString() on it.
If you want to revert the value you need to either set it back to what it was or configure the JFormattedTextField to REVERT or COMMIT_REVERT on losing focus.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Jacky Luk, please BeForthrightWhenCrossPostingToOtherSites.
https://forums.oracle.com/forums/thread.jspa?threadID=2501502
|
 |
 |
|
|
subject: How to expose processFocusEvent when JFormattedTextField is already opened?
|
|
|