 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Costis Aivalis Guest
|
Posted: Tue Aug 12, 2003 9:07 am Post subject: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
is there a way to enforce such patterns as a rule during dataentry in
swing?
Thank you
Costis Aivalis
|
|
| Back to top |
|
 |
Peter Schoaff Guest
|
Posted: Tue Aug 12, 2003 3:48 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Costis Aivalis <costis (AT) teicrete (DOT) gr> wrote
| Quote: | is there a way to enforce such patterns as a rule during dataentry in
swing?
Thank you
Costis Aivalis
|
Create a Document class which extends something like
javax.swing.text.PlainDocument. In this document override insertString
and put whatever rules you want to enforce there.
Then setDocument on the data entry field to an instance of this new class.
|
|
| Back to top |
|
 |
Tor Iver Wilhelmsen Guest
|
Posted: Tue Aug 12, 2003 4:54 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Costis Aivalis <costis (AT) teicrete (DOT) gr> writes:
| Quote: | is there a way to enforce such patterns as a rule during dataentry in
swing?
|
Use an InputVerifier, or for 1.4.x use a JFormattedTextField.
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Tue Aug 12, 2003 6:59 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
On Tue, 12 Aug 2003 12:07:00 +0300, Costis Aivalis
<costis (AT) teicrete (DOT) gr> wrote or quoted :
| Quote: | is there a way to enforce such patterns as a rule during dataentry in
swing?
|
for dates there is SimpleDateFormat.parse. see
http://mindprod.com/jgloss/calendar.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
|
|
| Back to top |
|
 |
Peter Schoaff Guest
|
Posted: Tue Aug 12, 2003 11:58 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Tor Iver Wilhelmsen <tor.iver.wilhelmsen (AT) broadpark (DOT) no> wrote
| Quote: | Costis Aivalis <costis (AT) teicrete (DOT) gr> writes:
is there a way to enforce such patterns as a rule during dataentry in
swing?
Use an InputVerifier, or for 1.4.x use a JFormattedTextField.
|
I'd missed that addition to 1.4. It's a much better solution than mine.
Please disregard my previous answer ;-)
|
|
| Back to top |
|
 |
Costis Aivalis Guest
|
Posted: Wed Aug 13, 2003 8:06 am Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Peter Schoaff wrote:
| Quote: | Tor Iver Wilhelmsen <tor.iver.wilhelmsen (AT) broadpark (DOT) no> wrote
Costis Aivalis <costis (AT) teicrete (DOT) gr> writes:
is there a way to enforce such patterns as a rule during dataentry in
swing?
Use an InputVerifier, or for 1.4.x use a JFormattedTextField.
I'd missed that addition to 1.4. It's a much better solution than mine.
Please disregard my previous answer
|
Thanx to all!
i am aware of the InputVerifier class. It gives an acceptable
after-entry control.
I am trying though, to force the user to enter the right type of data or
_beep_ during data entry.
I wanted to avoid writing my own controls to check every character
entered like a did a few years back in C, and i was hoping that this
would be already implemented, so that the rules could easily be set for
the SunOne-Forte or NetBean GUIS.
It is a perpetual necessity for every application. Even VB comes with
this feature i think they call it a data=entry-mask or something.
Costis Aivalis
|
|
| Back to top |
|
 |
David Segall Guest
|
Posted: Wed Aug 13, 2003 12:58 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Costis Aivalis <costis (AT) teicrete (DOT) gr> wrote:
| Quote: |
Peter Schoaff wrote:
Tor Iver Wilhelmsen <tor.iver.wilhelmsen (AT) broadpark (DOT) no> wrote
Costis Aivalis <costis (AT) teicrete (DOT) gr> writes:
is there a way to enforce such patterns as a rule during dataentry in
swing?
Use an InputVerifier, or for 1.4.x use a JFormattedTextField.
I'd missed that addition to 1.4. It's a much better solution than mine.
Please disregard my previous answer ;-)
Thanx to all!
i am aware of the InputVerifier class. It gives an acceptable
after-entry control.
I am trying though, to force the user to enter the right type of data or
_beep_ during data entry.
I wanted to avoid writing my own controls to check every character
entered like a did a few years back in C, and i was hoping that this
would be already implemented, so that the rules could easily be set for
the SunOne-Forte or NetBean GUIS.
It is a perpetual necessity for every application. Even VB comes with
this feature i think they call it a data=entry-mask or something.
VB does come with this "feature" and it shows an infuriating disregard |
for modern user interfaces. It ignores the fact the user can use the
mouse to enter data anywhere in the field in any order they choose. If
I want to enter the year before I enter the day and month or cut and
paste a temporarily invalid figure from a U.S. spreadsheet into a
European application, I should be allowed to. The feature was
invaluable on card and paper tape punches; now it's time to let the
user decide how to enter the field and check it when (s)he has
finished.
|
|
| Back to top |
|
 |
Tor Iver Wilhelmsen Guest
|
Posted: Wed Aug 13, 2003 2:15 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Costis Aivalis <costis (AT) teicrete (DOT) gr> writes:
| Quote: | I am trying though, to force the user to enter the right type of data
or _beep_ during data entry.
|
Borland's JBCL components have this if you have an older JBuilder Pro
or Enterprise available.
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Thu Aug 14, 2003 4:44 am Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
On Wed, 13 Aug 2003 12:58:57 GMT, David Segall <david (AT) segall (DOT) net>
wrote or quoted :
| Quote: | he feature was
invaluable on card and paper tape punches; now it's time to let the
user decide how to enter the field and check it when (s)he has
|
If you paste into subfields, you can still warn of errors at the time
of paste or of keystroke. The general rule is, the sooner the error
is reported the easier it is to correct. It also tends to build more
accurate typing reflexes.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
|
|
| Back to top |
|
 |
David Segall Guest
|
Posted: Thu Aug 14, 2003 2:37 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
Roedy Green <roedy (AT) mindprod (DOT) com> wrote:
| Quote: | On Wed, 13 Aug 2003 12:58:57 GMT, David Segall
wrote or quoted :
he feature was
invaluable on card and paper tape punches; now it's time to let the
user decide how to enter the field and check it when (s)he has
If you paste into subfields, you can still warn of errors at the time
of paste or of keystroke. The general rule is, the sooner the error
is reported the easier it is to correct. It also tends to build more
accurate typing reflexes.
I cannot disagree with your "general rule". However, it is very |
irritating if I attempt to paste 1,234,456.78 into a European program
and have it rejected before I get the chance to change the commas to
full stops and vice versa. The subfield idea also limits cutting and
pasting as you will have found if you have tried to paste the 19
character serial number of your Microsoft program from the text file
on the "gold" CD into the 4 character subfield. :)
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Thu Aug 14, 2003 10:38 pm Post subject: Re: "dd/MM/yy", "AAA", "!AA", "hh:mm:ss" inside jTextFields |
|
|
On Thu, 14 Aug 2003 14:37:44 GMT, David Segall <david (AT) segall (DOT) net>
wrote or quoted :
| Quote: | if I attempt to paste 1,234,456.78 into a European program
and have it rejected before I get the chance to change the commas to
full stops and vice versa.
|
There are several ways the reject could be done.
1. reject the paste as if it never happened. The problem with this is
the user is at loss to know precisely what the matter is, or to be
able to correct it.
2. accept the paste, but ignore the invalid chars in the paste,
leaving the originals in place. You might replace the invalid chars
with spaces or something else appropriate.
3. accept the paste but highlight the invalid characters. Don't accept
the field until those are fixed. It is still good to let the user
know as soon as possible the error has been made, even if you don't
force him to fix it immediately.
4. For individual keystroke errors, I find the kindest way to deal
with invalid keystrokes is just to ignore them and make a tiny blip
noise. You can do some friendly things, like convert letters to
numbers in phone number fields in case people are giving you cute
mnemonics. You can auto upper or autolower case, and not complain if
the user types the opposite. You can auto hop over spaces and other
decorative punctuation in fields so that the user does not have to
type it or space over it.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|