26) Implement a GUI based java program which should have a login page and should take in
ID and password as login credentials. Then it should display all the notes that were
previously saved by the user. It should give him the option to delete previous notes and
also add new notes.
Answers
Answer:
hajhs hsjab hshfsj hsjdbsbka jajsk
Explanation:
follow me
Answer:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LoginDemo extends JFrame implements ActionListener {
JPanel panel;
JLabel user_label, password_label, message;
JTextField userName_text;
JPasswordField password_text;
JButton submit, cancel;
LoginDemo() {
// Username Label
user_label = new JLabel();
user_label.setText("User ID :");
userName_text = new JTextField();
// Password Label
password_label = new JLabel();
password_label.setText("Password :");
password_text = new JPasswordField();
// Submit
submit = new JButton("SUBMIT");
panel = new JPanel(new GridLayout(3, 1));
panel.add(user_label);
panel.add(userName_text);
panel.add(password_label);
panel.add(password_text);
message = new JLabel();
panel.add(message);
panel.add(submit);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Adding the listeners to components..
submit.addActionListener(this);
add(panel, BorderLayout.CENTER);
setTitle("Please Login Here !");
setSize(450,350);
setVisible(true);
}
public static void main(String[] args) {
new LoginDemo();
}
@Override
public void actionPerformed(ActionEvent ae) {
String userName = userName_text.getText();
String password = password_text.getText();
if (userName.trim().equals("admin") && password.trim().equals("admin")) {
message.setText(" Hello " + userName + "");
} else {
message.setText(" Invalid user.. ");
}
}
}
Explanation:
The above java program will give hello message on successful login and display Notes. Other wise display Invalid user message.