Hi all,
I want to validate componentTextField, if these field is null or left blank and click the enter button, it must display an error message. Also need to validate the URL that is entered.
Can anyone help in this regard.
Thanks in advance.
Printable View
Hi all,
I want to validate componentTextField, if these field is null or left blank and click the enter button, it must display an error message. Also need to validate the URL that is entered.
Can anyone help in this regard.
Thanks in advance.
Hello,
Take a look at this code example - http://www.javaprogrammingforums.com...pressions.html
You can put the code here:
Code Java:enterbutton.setText("Enter"); gridConstraints.gridx = 1; gridConstraints.gridy = 5; getContentPane().add(enterbutton, gridConstraints); enterbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enterbuttonActionPerformed(e); // validate } });
You can check if something has been entered in the URLTextField by:
Code Java:if(URLTextField.getText().equals("")){ //nothing has been entered } else{ //validate }
Thanks for your help. Using Regular expression was able to validate given URL.