0% found this document useful (0 votes)
15 views2 pages

Swingform

The document contains code for a login form application with username and password validation. It has two classes - one for the login form with fields, buttons and validation logic. The second class is for a welcome page displayed after successful login.

Uploaded by

Shubham Pakhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Swingform

The document contains code for a login form application with username and password validation. It has two classes - one for the login form with fields, buttons and validation logic. The second class is for a welcome page displayed after successful login.

Uploaded by

Shubham Pakhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1st class = passwordId

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package advjavanxtexmp;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

/**
*
* @author shubh
*/
public class passwordId extends JFrame implements ActionListener {
JButton b1;
JPanel newPanel;
JLabel UserLabel,PassLabel;
JTextField textField1,textField2;
passwordId()
{
UserLabel=new JLabel();
UserLabel.setText("username");

textField1=new JTextField(15);

PassLabel=new JLabel();
PassLabel.setText("password");

textField2=new JPasswordField(15);

b1=new JButton("submit");

newPanel=new JPanel(new GridLayout(20,0));


newPanel.add(UserLabel);
newPanel.add(textField1);
newPanel.add(PassLabel);
newPanel.add(textField2);
newPanel.add(b1);

add(newPanel,BorderLayout.CENTER);
b1.addActionListener(this);
setTitle("LOGIN FORM");
}
public void actionPerformed(ActionEvent ae)
{
String userValue=textField1.getText();
String passValue=textField2.getText();

if(userValue.equals("[email protected]")&& passValue.equals("shiva")){
NewPage page=new NewPage();

page.setVisible(true);
JLabel wel_label=new JLabel("welcome: "+userValue);
page.getContentPane().add(wel_label);

}
else{
System.out.println("please enter valid username and password");
}
}
}
class LoginFormDemo
{
public static void main(String[] args) {
try{

passwordId form=new passwordId();


form.setSize(1000,1000);
form.setVisible(true);
}
catch(Exception e){

JOptionPane.showMessageDialog(null, e.getMessage());
}
}

2nd class=NewPage

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package advjavanxtexmp;

import javax.swing.JFrame;

/**
*
* @author shubh
*/

class NewPage extends JFrame


{
NewPage()
{
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("welcome back");
setSize(400,200);
}}

You might also like