Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // package AdminSignIn;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import javax.swing.JLabel;
- import javax.swing.JPasswordField;
- import javax.swing.JButton;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import javax.swing.WindowConstants;
- import javax.swing.GroupLayout;
- import javax.swing.GroupLayout.Alignment;
- import javax.swing.LayoutStyle.ComponentPlacement;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class SignIn extends JFrame {
- JLabel emailAddress;
- JTextField emailField;
- JLabel password;
- JPasswordField passwordField;
- JButton signIn;
- JLabel userName;
- JTextField usernameField;
- String title;
- public SignIn() { }
- public SignIn(String title) {
- super(title);
- this.userName = new JLabel();
- this.emailAddress = new JLabel();
- this.password = new JLabel();
- this.signIn = new JButton();
- this.usernameField = new JTextField();
- this.emailField = new JTextField();
- this.passwordField = new JPasswordField();
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.userName.setText("username");
- this.emailAddress.setText("email");
- this.password.setText("password");
- this.signIn.setText("SignIn");
- this.usernameField.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- usernameFieldActionPerformed(evt);
- }
- });
- GroupLayout layout = new GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- // horizontal orientation
- layout.setHorizontalGroup(
- layout.createParallelGroup(Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(127, 127, 127)
- .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
- .addComponent(emailAddress, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(password, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(userName, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGap(135, 135, 135)
- .addGroup(layout.createParallelGroup(Alignment.LEADING, false)
- .addComponent(emailField)
- .addComponent(passwordField, GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
- .addComponent(usernameField))
- .addContainerGap(138, Short.MAX_VALUE))
- .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(signIn)
- .addGap(133, 133, 133))
- );
- // Vertical orientation
- layout.setVerticalGroup(
- layout.createParallelGroup(Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(132, 132, 132)
- .addGroup(layout.createParallelGroup(Alignment.BASELINE)
- .addComponent(userName, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
- .addComponent(usernameField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
- .addGap(37, 37, 37)
- .addGroup(layout.createParallelGroup(Alignment.BASELINE)
- .addComponent(emailAddress, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
- .addComponent(emailField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
- .addGap(45, 45, 45)
- .addGroup(layout.createParallelGroup(Alignment.BASELINE)
- .addComponent(password, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
- .addComponent(passwordField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
- .addComponent(signIn)
- .addGap(83, 83, 83))
- );
- this.setVisible(true);
- pack();
- }
- private void usernameFieldActionPerformed(ActionEvent evt) {
- // TODO handling code here:
- }
- public static void main(String args[]) {
- SignIn sample = new SignIn("SignIn Form");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement