joptionpane validation

joptionpane validation

import javax.swing.*; import java.util.regex.*; public class joptionpane { public static void main(String[] args){ int category_user = 0; boolean aa = false; do{ String input = JOptionPane.showInputDialog( null,

            "Please select the category \n"
                + "1. IT \n"
                + "2. Science \n"
                + "3. Maths",

                "Input",

                JOptionPane.INFORMATION_MESSAGE
            );
            Pattern p = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
            Matcher m = p.matcher(input);
            if (m.find()) {
         JOptionPane.showMessageDialog(null, "Please enter only numbers");
            }
            else (m.find())
                    {
             category_user = Integer.parseInt(input);

            }
    }while (!aa || category_user < 1 || category_user>4);

}

\ hello!!please help me!i need to validate the user input on the joptionpane,and if the user enter is a character then it is supposed to return the select category question again.if the user enter correct then the loop will break.however, the following do while will keep looping!how do i modify the codes to make it right?thank for your help.

View Answers









Related Tutorials/Questions & Answers:
joptionpane validation
joptionpane validation  import javax.swing.*; import java.util.regex.*; public class joptionpane { public static void main(String[] args... help me!i need to validate the user input on the joptionpane,and if the user
JOptionPane Validation
JOptionPane Validation JOptionPane allow you to create dialog boxes easily... look complex. Here we are going to validate the textfield of JoptionPane dialog. JOptionPane String Validation We have used regular expression that 
Advertisements
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane validation. I have joptionpane inputdialog textbox.I need to enter the string values only in the textbox for validation. Please send the sample code immediately. Its very urgent
joptionpane - Java Beginners
joptionpane   I need joptionpane showinputdialog textbox integer validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane showinputdialog textbox string validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
joptionpane - Java Beginners
joptionpane  Hi, I need to hide the joptionpane message dialogs... java.util.regex.*; class Validation extends JFrame{ JTextField text; JLabel l1,l2; JPanel p; Validation(){ text=new JTextField(15); l1=new JLabel
validation
validation  validation
Array in JOptionPane - Java Beginners
Array in JOptionPane  Hello, I'm having trouble with printing an array in a JOptionPane. I am supposed to make a 2 dimensional int array called BlasTable. I'm supposed to use a method to print the array in a JOptionPane
joptionpane - Java Beginners
joptionpane  Hi, I need to change the JOptionpane foreground text color only. Please send the sample code. JOptionPane.showMessageDialog(createqmbutton, "Succesfully Create the Queue Manager", "Create Queue
Selection Using JoptionPane
Selection Using JoptionPane  Help, can someone provide me the code using JOptionPane for the following:- Part A 1) Prompt user to make 3 selection i.e 1)Orchid $4.00 2)Rose $2.50 3)Daisy $5.00 or 0 to Quit 2) if user
Get and Display using JOptionPane
from student, name and age, by using JOptionPane. Then display it. Really
JOptionPane - Java Beginners
and output should be via JOptionPane dialogue boxes. Examples are shown below
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
Set Color in JOptionPane
Set Color in JOptionPane       In this section, you will learn how to set color in JOptionPane. Now to do... following key value pair, we have set the background color for JOptionPane
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter only numerical values in textbox , if he enters string values then it should
Set delay time in JOptionPane
Set delay time in JOptionPane       In this section, you will learn how to set the time after which the message should be displayed using JOptionpane. For this, first of all we prompt
Set text color in JoptionPane
Set text color in JoptionPane In this section, you will learn how to set text color in JOptionPane. Now to do this, we have used UIManager class which... color for JOptionPane and background color for JPanel: um.put
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put
Validation
); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class="col1"> <label>Sno:</label> </td> <td
Java ComboBox in JOptionPane
Java ComboBox in JOptionPane In this section, you will learn how to create combo box in JOptionPane dialog box. We have created a button to perform an action.On clicking the button, you will get the dialog box with combo box in it. 
Display JList value selected from the JOptionPane
Display JList value selected from the JOptionPane In this section, we are going to select the particular value from the JOptionPane combobox and displayed.... To proceed further, when the user click the button, the JOptionPane with combobox
validation files
validation files  If I place validation files in the folder where the action classes are present,will there any error arise
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
While Loop with JOptionPane
Validation - Struts
Validation  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
form validation
form validation  how the form validation is done in jsf form using javaScript
validation query
validation query  where I should kept properties file inside struts Web application
email validation
email validation  during email validation.... after domain name which it means if example [email protected] .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
Validation of datepicker
Validation of datepicker  I have a datepicker in my JSp...the seleted dates are put in a text box. I want the alert the user from selecting future... a future date is entered..How to do this validation in javascript or jsp
email validation
email validation  during email validation.... after domain name which it means if example [email protected] .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
Date Validation
Date Validation  Hi, I need Date Validation using java in spring framework. Please Anyone help me... Thanks in advance
validation - Framework
validation  how to validate the action forms in struts? could you please explain how cross validation is done for date?  You go the following url: http://www.roseindia.net/struts/struts-login-form.shtml
date validation
date validation  sir, pls provide date validation code in javascript..we want to include it into our master form..   Please visit the following link: http://www.roseindia.net/mysql/datevalidation.shtml
Struts validation
Struts validation  I want to put validation rules on my project.But after following all the rules I can't find the result. I have extended... validation rules,put the plugins inside strutsconfig.xml, put the html:errors tag
Validation - Struts
Validation  How can i use validation framework i don't understand am...; Hi friend, Phone validation using javaScript function... return true; } Phone Validation
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try to put string values its not allowing to do tht it gives us message its right
Server side validation vs client side validation
Server side validation vs client side validation  Can any one tell me the difference between these two different ways of Validation? Also features of Server side validation vs client side validation.   The client side
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
validation
Validation
Validation
validation
Validation
Validation

Ads