Swing program

Swing program

Write a java swing program to get name and email id. Display the error message if email id is not in [email protected] format.

View Answers

April 12, 2011 at 12:19 PM

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.regex.*;
class  FormData{
    public static boolean isEmailValid(String email) {
        boolean isValid = false;
        String expression = "^[\\w\\.-][email protected]([\\w\\-]+\\.)+[A-Z]{2,4}$";
        CharSequence inputStr = email;
        Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(inputStr);
        if (matcher.matches()) {
            isValid = true;
        }
        return isValid;
    }

    public static void main(String[] args){
    Frame f=new Frame();
    Label label1=new Label("Name: ");
    Label label2=new Label("Email: ");
    final TextField text1=new TextField(20);
    final TextField text2=new TextField(20);
    Button b=new Button("Check");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        String v1=text1.getText();
        String v2=text2.getText();
        if(isEmailValid(v2) != true) {
        JOptionPane.showMessageDialog(null,"Invalid Email!");
        text2.setText("");
        }

        }
    });
        Panel p=new Panel(new GridLayout(3,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}









Related Tutorials/Questions & Answers:
Swing Program
Swing Program  Write a java swing program to calculate the age from given date of birth
swing program
swing program  Write a java swing program to getname and email id. Display the message if email id contains the name of theuser
Advertisements
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
Swing Program
Swing Program  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
Swing program
Swing program  Write a java swing program to get name and email id. Display the error message if email id is not in [email protected] format.   import java.awt.*; import java.sql.*; import javax.swing.*; import
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
swing program
swing program  Iam using one JFrame and 4 JPanels one JTabbedPane. my problem is next, previous buttons. when click next button visible some JPanels,again press visble another JPanels. also previous button. how to write the logic
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
Program for Calculator - Swing AWT
Program for Calculator  write a program for calculator?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope that it will be helpful
Java Program - Swing AWT
Java Program  A program to create a simple game using swings.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/swing/guessNumber.html Thanks
swing chatt program
swing chatt program  how to invoke the code from JTextArea to Socket   package magesh; import java.net.Socket; import java.io.DataInputStream; import java.io.PrintStream; public class Client { public Client
Java Program - Swing AWT
Java Program  A Java Program that display image on ImageIcon after selecting an image from the JFileChooser
Java Program - Swing AWT
Java Program  A Java Program to send message from one computer to another
Java Program - Swing AWT
Java Program  A java Program that send message from one computer to another and what are the requirements
Java Program - Swing AWT
Java Program  Write a Program that display JFileChooser that open a JPG Image and After Loading it Saves that Image using JFileChooser  Hi Friend, Try the following code: import java.io.*; import java.sql.
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
opening internet browser in java program - Swing AWT
opening internet browser in java program  i want a code to open the internet browser in swing program using JFrame.  Hi Omkar, Use the following code: 1) 'OpenBrowser.java' import javax.swing.*; import
swing
swing  Write a java swing program to delete a selected record from a table
problem in swing program for opening two windows with same login credentials
problem in swing program for opening two windows with same login credentials  I Face two problems while writing the code in swing program 1.i developed one application using swings that has username,password when i login
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
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
java program for Denial of Service (DoS) attacks detection - Swing AWT
java program for Denial of Service (DoS) attacks detection  i want a simple program to generate and detect a Denial of Service (DoS) attacks. using java program
swing
swing  How to make swing component auto-resizable when JFrame resize
Writing Calculator Program in Swing
Writing Calculator Program in Swing   ... illustrates you how to a create calculator in Swing with the source code and screen shot. For developing a small calculator program in swing we need two different
Swing
Swing  Hi, I need a program to read text from a text file to Jframe directly without browsing. Thank u   Please visit the following link: Extract file data to JTable
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
Java - Swing AWT
Java  write a swing program to display the contents of a database in a JTable
ModuleNotFoundError: No module named 'swing'
ModuleNotFoundError: No module named 'swing'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'swing' How to remove the ModuleNotFoundError: No module named 'swing'
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
swing-awt - Swing AWT
swing-awt  Hi, Thanks for replying to my question...I'm getting some confusion to add action events in my application(Rich Text Editor).How to add action events? Thank U
Java Swing Tutorials
and you can use it in your program. Java Swing tutorials first gives you brief... a Frame   This program shows you how to create a frame in Java Swing... points.      Writing Calculator program in Swing
What is Swing?
What is Swing?  What is Java Swing? Where to get the tutorials of Swing? I am beginner in Java Swing programming and trying to find the tutorials of Swing. Tell me the urls to learn swing. Thanks   Hi, Swing is Java
swing/awt - Swing AWT
swing/awt  How to create richtexteditor using swings...?I'm very much new to swings....It's urgent.....Thank u...   hello read this book you get idea; JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second
Swing paint - Swing AWT
Swing paint  hi, i want to print something on window using swing applet.. m doing dis.. protected void paintComponent(Graphics g... the Swing Applet, use html file with the following code: Java Applet Demo
program
program  any program of hotel or school management
swing sms
swing sms  HOW TO SEND SMS MESSAGE FROM SWING USING SQL DATABASE
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
swing to applet
swing to applet  hi how i can isplay a java swing into applet java thanks
program
program  program of jdbc using ms access for creating table
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
program
program  write a javascript program to create a application form with validation
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes

Ads