java 10 updated
Rohit143
java
4 years ago
1.4 kB
29
Indexable
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyJFrame extends JFrame{
JLabel username,password,datalLabel;
JTextField usernameField;
JPasswordField passwordField;
JButton login;
MyJFrame(){
setLayout(new FlowLayout());
setVisible(true);
setDefaultCloseOperation(3);
setSize(350, 500);
username= new JLabel("Username : ");
usernameField =new JTextField(20);
password= new JLabel("Password : ");
passwordField =new JPasswordField(20);
login=new JButton("Login");
datalLabel =new JLabel("Username and Password will be displayed here ");
JLabel name =new JLabel("by Rohit Nandagawali");
add(username);
add(usernameField);
add(password);
add(passwordField);
add(login);
add(datalLabel);
add(name);
login.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
String data ="Your Username : "+usernameField.getText()+", Your Password : "+new String(passwordField.getPassword());
datalLabel.setText(data);
validate();
}
});
}
}
public class practical12 {
public static void main(String[] args) {
new MyJFrame();
}
}Editor is loading...