Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. package com.edu4java.swing.tutrial3;
  2.  
  3. import javax.swing.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. public class LoginView {
  8.  
  9.  
  10. public static void main(String[] args) {
  11. JFrame frame = new JFrame("Bus Tour Booking System");
  12. frame.setSize(300, 200);
  13. frame.setResizable(false);
  14. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  15.  
  16. JPanel panel = new JPanel();
  17. frame.add(panel);
  18. placeComponents(panel);
  19.  
  20. frame.setVisible(true);
  21. }
  22.  
  23. private static void placeComponents(JPanel panel) {
  24.  
  25. panel.setLayout(null);
  26.  
  27. JLabel titleLabel = new JLabel("Bus Tour Booking System");
  28. titleLabel.setBounds(70,15,150,25);
  29. panel.add(titleLabel);
  30.  
  31. JLabel userLabel = new JLabel("Username: ");
  32. userLabel.setBounds(30, 50, 80, 25);
  33. panel.add(userLabel);
  34.  
  35. JTextField userText = new JTextField(20);
  36. userText.setBounds(120, 50, 130, 25);
  37. panel.add(userText);
  38.  
  39. JLabel passwordLabel = new JLabel("Password: ");
  40. passwordLabel.setBounds(30, 80, 80, 25);
  41. panel.add(passwordLabel);
  42.  
  43. JPasswordField passwordText = new JPasswordField(20);
  44. passwordText.setBounds(120, 80, 130, 25);
  45. panel.add(passwordText);
  46.  
  47. JButton loginButton = new JButton("login");
  48. loginButton.setBounds(100, 125, 80, 25);
  49. panel.add(loginButton);
  50.  
  51. ActionListener myButtonListener = new MyButtonListener();
  52. loginButton.addActionListener(myButtonListener);
  53.  
  54. }
  55.  
  56. private static class MyButtonListener implements ActionListener {
  57. @Override
  58. public void actionPerformed(ActionEvent e) {
  59. //here
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement