Hi Dwalin,
...As you might have seen, I have researched the different options of checking for the time to validate a textfields content, as I refer to the action events (enter key, can also be done by a keyboard event), lostfocus event, which normally is the time to forward an entered value to an underlying classes object, unless some binding can be done that automizes the exchange between an object's property and the textfields text property and also handles a "data dirty" flag. The API looks not "fine-grained" to me, but overloaded, leaving out options that are standard for decades to users of many OSses, hopelessly redundant in many places, where loads of old libs/workspaces should become obsolete, but aren't to keep compatibility for some apps that have been written 10 yearas ago and a lot more
to nag.
However, I also see some advantages for Java/NetBeans, just not for GUI development. Maybe Java offers solutions, maybe the NetBeans GUI builder supports it, but then I find most tutorials too incompletely to give the right idea. I should expect that I can bind visual component's properties to properties of my own classes, but can't find an tutorial to see how that is done, and how it is done with NetBeans GUI builder.
I didn't mean to imply that you didn't know what you were doing. But as
with everything, there are many different ways to skin a cat. In the
Swing projects I've worked on, we've typically extended the standard
Swing components with more specialized ones and had those components
emit abstract events that "application-level" listeners would act on.
For instance, we would implement a ModifiableTextField component that
emits a "Modified" event whenever the inputted text changed from some
initial value. The listener might be a controller - e.g. the containing
panel - who then decides whether to update the corresponding data
object/model.
The specialized components deal with whatever low-level mechanism is
necessary to determine whether something's "changed". In the case of
the JTextField, I would use a DocumentChangeListener - because that
tells me 100% of the time when something's changed and lets me send the
"modified" event at the appropriate times. Similarly, in the case of
the various buttons, I'd internally use an ActionListener; in the case
of JComboBox, an ItemStateListener, etc.
The above methodology may not be optimal in term of the number of events
different components need to listen to internally, but at least external
to the components the events are at "just the right level". Another
benefit, although probably not that important, is that it insulates much
of the application from Swing-specifics. In the case of Java/Swing this
is not as important anymore, but back in the 80's I worked on a couple
of projects that used very sophisticated but proprietary APIs and when
the company went belly up (does anyone remember Visigenics' "Galaxy"
framework), all the code that was so tightly coupled to the proprietary
API had to be rewritten. That is a lesson I took from those days.
Well, enough said. Maybe in the end, I'm making much ado about nothing
- maybe I'm just defending Swing because I've been quite happy with it
for such a long time. Although I've never had the "pleasure" of
developing anything using Microsoft's toolkits, I have used quite a few
GUI toolkits: a bunch of C and C++ X11 toolkits (Athena, OpenLook, and
Motif), NeXTStep, cross-platform C++ GUIs (zApp, Galaxy, a couple other
proprietaray ones I can't remember), and I can honestly say that
Java/Swing has been the easiest to work with - for me.
Best wishes,
tom
**********************************************************************************************
IMPORTANT: The contents of this email and any attachments are confidential. They are intended for the
named recipient(s) only.
If you have received this email in error, please notify the system manager or the sender immediately and do
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**********************************************************************************************