Swingform
Swingform
/*
* 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");
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{
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
*/