• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to expose processFocusEvent when JFormattedTextField is already opened?

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stop using the IDE wizard.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brilliant, Darryl
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any ideas?
Thanks
Jack
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jacky Luk, please BeForthrightWhenCrossPostingToOtherSites.
https://forums.oracle.com/forums/thread.jspa?threadID=2501502
 
reply
    Bookmark Topic Watch Topic
  • New Topic