File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JFormattedTextField problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFormattedTextField problem" Watch "JFormattedTextField problem" New topic
Author

JFormattedTextField problem

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear Ranchers,

I'm developing an application in Java Swings and Oracle. In my System, there is a tab called Customize where the user who logged in can able to customize the System as his own needs like

1. Look and Feel
2. Font Colors which he wants to enter
3. changing his profile
4. Changing the splash screen time out

In the Splash Screen time out, the default value which the system comes with is 5000 and the users are allowed to change the SplashScreen time out from 1 to 10,000

I'm using a JFormattedTextField to set the value

The code is as follows


But when i enter a value 100 in the JFormattedTextField and click the action, it is giving me errors



Please help me ranchers to sort this problem out.

Thanks in Advance

Aravind Prasad
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Aravind Prasad:
In the Splash Screen time out, the default value which the system comes with is 5000 and the users are allowed to change the SplashScreen time out from 1 to 10,000

I'm using a JFormattedTextField to set the value

But when i enter a value 100 in the JFormattedTextField and click the action, it is giving me errors


It seems to me that you are using JFormattedTextField the hard way. Wouldn't something like this be easier?



You could also consider new JSpinner(new SpinnerNumberModel(5000, 1000, 10000, 500)).

[edit: under java5 or later could simply call field.setValue(5000)--autoboxing]
[ October 23, 2007: Message edited by: Brian Cole ]

bitguru blog
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Thankyou Mr.Brian,

This is also good option, But I want the users only to enter a value which is having 4 digits and it should be greater than 1000. Meaning the number ranges from 1000 to 9999 only.

Please help me to sort out the problem in JFormattedTextField.

Thanks/Regards

Araavind
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Aravind Prasad:
This is also good option, But I want the users only to enter a value which is having 4 digits and it should be greater than 1000. Meaning the number ranges from 1000 to 9999 only.

Please help me to sort out the problem in JFormattedTextField.


Well ok, change nf.setMaximum(10000) to nf.setMaximum(9999) then. And leave out field.setValue() if you wish.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFormattedTextField problem