I am trying to develop a GUI application that has a text area for a 10 digit number. I would prefer to right click on the field and select a max length and "number type" instead of coding an 'if function on keypress' and so on. Is this possible?
I looked but didn't find anything, perhaps I'm not looking in the right places...
lol, no need to insult.. it's just a question - you probably don't know some minor things here and there either... you could've given me a 2 line answer if you knew this instead of making me read a huge document... I know how to make swing applications, I just don't know this one little thing.
All your dreams come true when you click on the component and check the Properties tab (normally on the right).
If by any chance you do not see this panel then from main menu select Window >> Properties or Ctrl+Shift+7
I am trying to develop a GUI application that has a text area for a 10 digit number. I would prefer to right click on the field and select a max length and "number type" instead of coding an 'if function on keypress' and so on. Is this possible?
I looked but didn't find anything, perhaps I'm not looking in the right places...
Thanks,
-Ashton.
I have checked properties of the text field many times, but did not find anything, that's why I made this thread.
PS: Why do I always have to argue with some big shot before I can get an answer on this website? It would work so much better if we were all willing to listen before talking I think.
I was looking for a Netbeans answer in specific, If there is no function like the one I'm looking for then I will move on and look at alternative methods. Thanks for your input.
I was looking for a Netbeans answer in specific, If there is no function like the one I'm looking for then I will move on and look at alternative methods. Thanks for your input.
-Ashton.
I'm an Eclipse user myself, so I can't address NetBeans, but I thought if NetBeans supports JFormattedTextField in its GUI builder (which it really should) then it should have the standard format options available for you to pick from including numeric type & length.
JTextField also doesn't let you set content type (unlike TextField in Java Microedition).
Use JFormattedTextField as James suggested. You will find it in NetBeans in Palette>> Swing Controls >> FormattedField. And to set content type in Properties look for formatterFactory and use drop down menu
I just played around with the JFormattedTextField and formatterFactory, and had a look at the API. The problem though, is that it formats the text after it has already been typed in where as my aim is to completely disable any other character except numbers. Is this not possible?
At the same time, to disable input once the 10th character has been entered (max length).