Alex Chard

Greenhorn
+ Follow
since Apr 05, 2011
Alex likes ...
Eclipse IDE Oracle
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alex Chard

Hi all

I hope there are some JGoodies users here.

I'm using a DefaultFormBuilder to build a panel of my dialog. It's all working, but there's one nice to have that I'd like to do.
Is it possible to set the labelFor property of the separator to point to the next Component (a JScrollPane containing a JTextArea) using the mnemonic of the separator?

What I have so far is:
So in this case, I'd like Alt + B to take focus on the scrollPane component.

Any thoughts appreciated.
12 years ago
Just to let you all know I sorted this by using the NumberFormatExt NumberFormat from the SwingX project.
This handles the blank fields, which the default NumberFormat won't allow.

Hope that helps someone.
12 years ago
Thanks for the reply. Next up is trying a Document Filter, but I was hoping to keep to a FormattedTextField.
12 years ago
OK, so a bit more investigation shows the following.

Firstly, the code snippet above is wrong. It should be:



The setAllowsInvalid line of code is what causes the behaviour I was seeing.
However, removing that means that any value can be entered in to the field, and it is only validated when the field is exited. Any invalid characters are then simply stripped from the text in the field.
The problem here is that the user can click the Next button on my form, and not notice the invalid characters.

I'm after a halfway house of the above behaviour, where an invalid character can't be entered, but a blank string can.

Any ideas appreciated.
12 years ago
Hi all

My first post here, and I'm relatively new to Java programming, although I've been an Oracle developer for over a decade now.

On to my problem.

I need to create a field on a form that only allows the user to input whole numbers (integers).

I've implemented this as follows:

This works in the sense that it only allows integer values in the field, and along with other code, does just about everything I need.
The only problem I have is changing the number entirely. The numberFormatter will not let me delete the last character in the field.

E.g.
If the initial value is 600,000, and I delete the 6, the field shows 0. I cannot delete this zero so that the field is empty, which I need to do.
If I delete the zeros one after the other, I am left with a 6 that I can't delete.

This is not good, because to update the field from 600,000 to 12 (for example), I have to do the following:
1. Delete all the zeros, leaving the 6.
2. Enter 12, meaning the value in the field is now 612, or 126 depending on how the initial value was modified by the user.
3. Delete the 6.

I've looked at the NumberFormatter and IntegerFormatter classes and documentation but can't see anything that allows the field to contain blank values.

Is there an option to allow an IntegerFormatter to have a blank field?
If not, can anyone suggest another way of doing this?

Thanks

Alex
12 years ago