Home Answers Viewqa Java-Beginners Validation in swing

 
 


Ragavan
Validation in swing
4 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners

I want to validate my swing program. If I didnt enter the field in text box a msgbox should have to appear that enter all the fields.
View Answers

February 3, 2010 at 2:47 PM


Hi Friend,

Try the following code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class SwingProgram{
public static void main(String args[]){
SwingProgram p=new SwingProgram();
}
public SwingProgram(){
JLabel label=new JLabel("Enter Name:");
final JTextField text=new JTextField(15);
JButton button=new JButton("Submit");
JFrame f=new JFrame();
f.getContentPane().setLayout(null);
label.setBounds(50,50,80,20);
text.setBounds(150,50,150,20);
button.setBounds(50,80,80,20);
f.add(label);
f.add(text);
f.add(button);
f.setSize(400,150);
f.setVisible(true);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String name=text.getText();
if((name.equals(""))||(name.equals(null))){
JOptionPane.showMessageDialog(null,"Please enter the field","Error",JOptionPane.ERROR_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"Welcome "+name);
}
}
});
}
}

Thanks

January 29, 2011 at 1:24 PM


i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code..


January 29, 2011 at 1:24 PM


i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code..


January 29, 2011 at 1:24 PM


i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code..









Related Pages:
Validation
Validation  Hi.. How to Validate blank textfield in java that can accepts only integers?   Have a look at the following link: http://www.roseindia.net/tutorial/java/swing/howtovalidatetextfield.html
Validation in swing - Java Beginners
Validation in swing  I want to validate my swing program. If I didnt enter the field in text box a msgbox should have to appear that enter all the fields.  Hi Friend, Try the following code: import java.awt.
validation - Swing AWT
by creating an object of another existed java swing class.As we have used the class
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
JTable Cell Validation? - Swing AWT
JTable Cell Validation?  hi there please i want a simple example...(table); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER...=new JFrame("JTable validation"); frame.add(label,BorderLayout.NORTH
JTextField Validation in java swing
JTextField Validation in java swing In this tutorial, you will learn how to validate jtextfield in java swing. Here we have created a textfield on frame and allowed the user to enter. If the user enter characters or symbols or special
Swing Program
Swing Program  write a java swing program to get user name and password. The name contains only characters while password is masked with the character "*". Apply checks for all validation
Swing Program
Swing Program  Write a java swing program that takes name and marks as input with all validation. The name and marks will be displayed in message box when user clicks on a button
validation
validation  validation
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
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
Swing Program
Swing Program  write a java swing program to get username and password. The name contains only characters while password is masked with the characters "*". Apply checks for all validation.   import javax.swing.*; import
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
Admission Validation - Java Beginners
on Swing Application is that "ADMISSION FULL",How I can Show that plz Help Me Sir
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 - Swing AWT
java  how can i validate textfield in swing?  Hi Friend... java.awt.event.*; import java.util.regex.*; class Validation extends JFrame{ JTextField text; JLabel l1,l2; JPanel p; Validation(){ text=new
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
java swing - Java Beginners
java swing  How to set the rang validation on textfield, compare validation textfields , and also if we create a groupbutton like male female, if we...(){ JFrame f = new JFrame("Frame in Java Swing"); f.getContentPane().setLayout(null
swing
swing  Write a java swing program to delete a selected record from a table
swing
swing  How to make swing component auto-resizable when JFrame resize
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
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
Validation - Struts
Validation  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
validation query
validation query  where I should kept properties file inside struts Web application
form validation
form validation  how the form validation is done in jsf form using javaScript
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... 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
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
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.