Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2003

Tip: Looking for answers? Try searching our database.

Finding help on Events and a small aside

Thread view: 
Eamon Reyn - 03 Nov 2003 02:40 GMT
Hi Guys,

I am writing a java application using lots of visual components. The Java
API help is good in that it tells me about all the constructors, methods and
fields associated with a given object but where can I find similar help on
the events that can be implemented.

I know I can probably just ask my question and get an answer on a group but
I am kind of a self help junkie and I tend to dislike bothering people and
sending excess emails.

And now my small aside

The question arises due to the fact that I want to utilize a JTextField but
only allow integers to be entered and I am looking for the right events to
use to do things like the following.

Any hints or other options would be appreciated

Stop people entering letters or invalid characters via key-presses (probably
a key-press event where I can gobble up erroneous keys but I still need to
allow field tabbing and backspace del etc)
Stop people entering letters via pasting (so switch off CTRL+V etc may
encounter cross platform issues on Mac and Unix)

Thanks Guys,
Eamon
Knute Johnson - 03 Nov 2003 17:01 GMT
> Hi Guys,
>
[quoted text clipped - 6 lines]
> I am kind of a self help junkie and I tend to dislike bothering people and
> sending excess emails.

A good table would be nice but I don't know where you can find one.  I
just look at the types of listeners that can be added.

> And now my small aside
>
[quoted text clipped - 9 lines]
> Stop people entering letters via pasting (so switch off CTRL+V etc may
> encounter cross platform issues on Mac and Unix)

You will need to override PlainDocument.

> Thanks Guys,
> Eamon

Signature

Knute Johnson
email s/nospam/knute/
Molon labe...

Martijn van Steenbergen - 04 Nov 2003 07:57 GMT
> The question arises due to the fact that I want to utilize a JTextField but
> only allow integers to be entered and I am looking for the right events to
> use to do things like the following.

Take a look at javax.swing.JFormattedTextfield:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFormattedTextField.html

There's also an article in the Java Tutorial on this:
http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html

Good luck!

Martijn.
big boy - 09 Nov 2003 08:39 GMT
As suggested, PlainDocument sounds like what you need. PlainDocument
is very simple to implement (refer
http://groups.google.co.nz/groups?q=%22plaindocument%22%22numeric%22&hl=en&lr=&i
e=UTF-8&selm=FEt636.9w7%40unx.sas.com&rnum=4
)
to ensure only numeric characters are implemented regardless of copy
and paste.

- big

> > The question arises due to the fact that I want to utilize a JTextField but
> > only allow integers to be entered and I am looking for the right events to
[quoted text clipped - 9 lines]
>
> Martijn.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.