Advertisement
Guest User

Untitled

a guest
Dec 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. import java.awt.EventQueue;
  2. import javax.swing.JFrame;
  3. import javax.swing.JTextField;
  4. import java.awt.BorderLayout;
  5. import javax.swing.GroupLayout;
  6. import javax.swing.GroupLayout.Alignment;
  7. import javax.swing.JLabel;
  8. import java.awt.Font;
  9. import javax.swing.LayoutStyle.ComponentPlacement;
  10. import javax.swing.JButton;
  11. import javax.swing.JPanel;
  12. import javax.swing.SwingConstants;
  13. import javax.swing.JPasswordField;
  14.  
  15. public class Login extends Mainscreen{
  16.  
  17. public JFrame loginframe;
  18. public JTextField tfUser;
  19. public JPasswordField tfPassword;
  20.  
  21. /**
  22. * Launch the application.
  23. */
  24. public static void main() {
  25.  
  26. EventQueue.invokeLater(new Runnable() {
  27. public void run() {
  28. try {
  29. Login window = new Login();
  30. window.loginframe.setVisible(true);
  31. } catch (Exception e) {
  32. e.printStackTrace();
  33. }
  34. }
  35. });
  36. }
  37.  
  38. /**
  39. * Create the application.
  40. */
  41. public Login() {
  42. super();
  43. initialize();
  44. }
  45.  
  46. /**
  47. * Initialize the contents of the frame.
  48. */
  49. private void initialize() {
  50. loginframe = new JFrame();
  51. loginframe.setBounds(100, 100, 200, 140);
  52.  
  53. JPanel loginpanel = new JPanel();
  54. loginframe.getContentPane().add(loginpanel, BorderLayout.CENTER);
  55.  
  56. JLabel lblUser = new JLabel("Benutzername:");
  57. lblUser.setFont(new Font("Tahoma", Font.PLAIN, 11));
  58.  
  59. tfUser = new JTextField();
  60. tfUser.setHorizontalAlignment(SwingConstants.LEFT);
  61. tfUser.setFont(new Font("Tahoma", Font.PLAIN, 11));
  62. tfUser.setColumns(10);
  63.  
  64. JLabel lblPassword = new JLabel("Passwort:");
  65. lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 11));
  66.  
  67. JButton btnLogin = new JButton("Login");
  68. btnLogin.setFont(new Font("Tahoma", Font.PLAIN, 11));
  69.  
  70. tfPassword = new JPasswordField();
  71. tfPassword.setFont(new Font("Tahoma", Font.PLAIN, 11));
  72. GroupLayout gl_loginpanel = new GroupLayout(loginpanel);
  73. gl_loginpanel.setHorizontalGroup(
  74. gl_loginpanel.createParallelGroup(Alignment.LEADING)
  75. .addGroup(gl_loginpanel.createSequentialGroup()
  76. .addContainerGap()
  77. .addGroup(gl_loginpanel.createParallelGroup(Alignment.LEADING, false)
  78. .addComponent(lblUser)
  79. .addComponent(tfUser)
  80. .addComponent(lblPassword)
  81. .addComponent(tfPassword))
  82. .addPreferredGap(ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
  83. .addComponent(btnLogin)
  84. .addContainerGap())
  85. );
  86. gl_loginpanel.setVerticalGroup(
  87. gl_loginpanel.createParallelGroup(Alignment.LEADING)
  88. .addGroup(gl_loginpanel.createSequentialGroup()
  89. .addContainerGap()
  90. .addComponent(lblUser)
  91. .addPreferredGap(ComponentPlacement.RELATED)
  92. .addGroup(gl_loginpanel.createParallelGroup(Alignment.BASELINE)
  93. .addComponent(tfUser, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  94. .addComponent(btnLogin))
  95. .addPreferredGap(ComponentPlacement.RELATED)
  96. .addComponent(lblPassword)
  97. .addPreferredGap(ComponentPlacement.RELATED)
  98. .addComponent(tfPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  99. .addContainerGap(39, Short.MAX_VALUE))
  100. );
  101. loginpanel.setLayout(gl_loginpanel);
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement