Hello everyone. I had a quick question. How can I go about setting constraitnts for a JTextField. I'm trying to not allow users to enter any non numeric numbers, except for dollar signs, commas and periods. Also how can I restrict a JTextField to only allowing two numbers to be entered. Like from 0-99. May someone give me an example to both please. Thanks in advance.
set up a KeyListener to it which refuses to allow anything you don't want.
May I get an example of how I would do that please. I don't know how to set up constraints at all. I don't really need it for what I'm doing but it would save me some trouble from throwing exceptions, unless the user copy and pastes the info into the textfield.
I tried some of the codes out and still couldn't find a solution. I'll give an example of what I'm trying to do. If I have a field named "JTextField num= new JTextField(10);", how can I make this particular field only accept number formats. It won't allow the user to input any letters at all before they even select enter.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...