Advertisement
Guest User

Untitled

a guest
Dec 25th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. // package AdminSignIn;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;
  4. import javax.swing.JTextField;
  5. import javax.swing.JLabel;
  6. import javax.swing.JPasswordField;
  7. import javax.swing.JButton;
  8. import javax.swing.JLabel;
  9. import javax.swing.JTextField;
  10. import javax.swing.WindowConstants;
  11. import javax.swing.GroupLayout;
  12. import javax.swing.GroupLayout.Alignment;
  13. import javax.swing.LayoutStyle.ComponentPlacement;
  14. import java.awt.event.ActionEvent;
  15. import java.awt.event.ActionListener;
  16.  
  17. public class SignIn extends JFrame {
  18.  
  19. JLabel emailAddress;
  20. JTextField emailField;
  21. JLabel password;
  22. JPasswordField passwordField;
  23. JButton signIn;
  24. JLabel userName;
  25. JTextField usernameField;
  26. String title;
  27.  
  28. public SignIn() { }
  29.  
  30. public SignIn(String title) {
  31. super(title);
  32. this.userName = new JLabel();
  33. this.emailAddress = new JLabel();
  34. this.password = new JLabel();
  35. this.signIn = new JButton();
  36. this.usernameField = new JTextField();
  37. this.emailField = new JTextField();
  38. this.passwordField = new JPasswordField();
  39.  
  40. this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  41.  
  42. this.userName.setText("username");
  43.  
  44. this.emailAddress.setText("email");
  45.  
  46. this.password.setText("password");
  47.  
  48. this.signIn.setText("SignIn");
  49.  
  50. this.usernameField.addActionListener(new ActionListener() {
  51. public void actionPerformed(ActionEvent evt) {
  52. usernameFieldActionPerformed(evt);
  53. }
  54. });
  55.  
  56. GroupLayout layout = new GroupLayout(getContentPane());
  57. getContentPane().setLayout(layout);
  58.  
  59. // horizontal orientation
  60. layout.setHorizontalGroup(
  61. layout.createParallelGroup(Alignment.LEADING)
  62. .addGroup(layout.createSequentialGroup()
  63. .addGap(127, 127, 127)
  64. .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
  65. .addComponent(emailAddress, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  66. .addComponent(password, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  67. .addComponent(userName, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  68. .addGap(135, 135, 135)
  69. .addGroup(layout.createParallelGroup(Alignment.LEADING, false)
  70. .addComponent(emailField)
  71. .addComponent(passwordField, GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
  72. .addComponent(usernameField))
  73. .addContainerGap(138, Short.MAX_VALUE))
  74. .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
  75. .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  76. .addComponent(signIn)
  77. .addGap(133, 133, 133))
  78. );
  79.  
  80. // Vertical orientation
  81. layout.setVerticalGroup(
  82. layout.createParallelGroup(Alignment.LEADING)
  83. .addGroup(layout.createSequentialGroup()
  84. .addGap(132, 132, 132)
  85. .addGroup(layout.createParallelGroup(Alignment.BASELINE)
  86. .addComponent(userName, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
  87. .addComponent(usernameField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
  88. .addGap(37, 37, 37)
  89. .addGroup(layout.createParallelGroup(Alignment.BASELINE)
  90. .addComponent(emailAddress, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
  91. .addComponent(emailField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
  92. .addGap(45, 45, 45)
  93. .addGroup(layout.createParallelGroup(Alignment.BASELINE)
  94. .addComponent(password, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
  95. .addComponent(passwordField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
  96. .addPreferredGap(ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
  97. .addComponent(signIn)
  98. .addGap(83, 83, 83))
  99. );
  100.  
  101. this.setVisible(true);
  102.  
  103. pack();
  104.  
  105. }
  106.  
  107.  
  108. private void usernameFieldActionPerformed(ActionEvent evt) {
  109. // TODO handling code here:
  110. }
  111.  
  112.  
  113. public static void main(String args[]) {
  114.  
  115. SignIn sample = new SignIn("SignIn Form");
  116. }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement