Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.JOptionPane;
- public class Sw extends JFrame implements ActionListener{
- JLabel unLabel, pwLabel;
- JTextField unTextField, pwTextField;
- JButton okButton, clearButton, exitButton;
- public Sw()
- {
- setLayout(null);
- unLabel = new JLabel("Username:");
- pwLabel = new JLabel("Password:");
- unTextField = new JTextField("");
- pwTextField = new JTextField("");
- okButton = new JButton("OK");
- clearButton = new JButton("RESET");
- exitButton = new JButton("EXIT");
- unLabel.setBounds(50, 50, 100, 20);
- pwLabel.setBounds(50, 80, 100, 20);
- unTextField.setBounds(150, 50, 100, 20);
- pwTextField.setBounds(150, 80, 100, 20);
- okButton.setBounds(50, 150, 100, 20);
- clearButton.setBounds(150, 150, 100, 20);
- exitButton.setBounds(250, 150, 100, 20);
- add(unLabel);
- add(pwLabel);
- add(unTextField);
- add(pwTextField);
- add(okButton);
- add(clearButton);
- add(exitButton);
- okButton.addActionListener(this);
- clearButton.addActionListener(this);
- exitButton.addActionListener(this);
- }
- public void actionPerformed(ActionEvent event)
- {
- if (event.getSource()==clearButton)
- {
- unTextField.setText("");
- pwTextField.setText("");
- }
- else if (event.getSource()==exitButton)
- {
- System.exit(0);
- }
- else
- {
- if((unTextField.getText().equals("admin"))&&(pwTextField.getText().equals("123")))
- {
- Sw me = new Sw();
- me.setSize(500, 300);
- me.setVisible(true);
- }
- }
- }
- public static void main(String[] args)
- {
- Sw login = new Sw();
- login.setSize(500, 300);
- login.setVisible(true);
- }
- }
- import java.awt.event.*;
- import java.awt.*;
- import javax.swing.*;
- import javax.swing.JOptionPane;
- public class DianaPerez extends JFrame implements ActionListener{
- JLabel SnLabel, LnLabel, FnLabel, SubLabel;
- JTextField SnTextField, LnTextField, FnTextfield, SubTextfield;
- JButton OkButton;
- public DianaPerez()
- {
- setLayout(null);
- SnLabel = new JLabel("Student Number: ");
- LnLabel = new JLabel("Last Name: ");
- FnLabel = new JLabel("First Name: ");
- SubLabel = new JLabel("Subject: ");
- SnTextField = new JTextField("");
- LnTextField = new JTextField("");
- FnTextfield = new JTextField("");
- SubTextfield = new JTextField("");
- OkButton = new JButton("OK");
- SnLabel.setBounds(50, 50, 100, 20);
- LnLabel.setBounds(50, 80, 100, 20);
- FnLabel.setBounds(50, 110, 100, 20);
- SubLabel.setBounds(50, 140, 100, 20);
- SnTextField.setBounds(150, 50, 100, 20);
- LnTextField.setBounds(150, 80, 100, 20);
- FnTextfield.setBounds(150, 110, 100, 20);
- SubTextfield.setBounds(150, 140, 100, 20);
- OkButton.setBounds(110, 180, 100, 20);
- add(SnLabel);
- add(LnLabel);
- add(FnLabel);
- add(SubLabel);
- add(SnTextField);
- add(LnTextField);
- add(FnTextfield);
- add(SubTextfield);
- add(OkButton);
- OkButton.addActionListener(this);
- }
- public void actionPerformed(ActionEvent event)
- {
- if (event.getSource()==OkButton)
- {
- JOptionPane.showMessageDialog(rootPane, "CONGRATULATIONS");
- }
- else
- {
- System.exit(0);
- }
- }
- public static void main(String[] args)
- {
- DianaPerez me = new DianaPerez();
- me.setSize(500, 300);
- me.setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment