• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFormattedTextField problem

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic