I want to design a simple form, having 5 components:
2 labels, 1 test field, 1 password text field, and 1 button. I want to have a label, and right to it the text field.
One line down (or more, a nice looking space should be seen) I want the second label, with the passwordtextfield to it's right.
In a third line below that, in the middle, I want the button.
I am trying to do this without WindowsBuilder or any assisting tool, however, I am a newbie in Java.
package HR;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JFormattedTextField;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class SignIn extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
public SignIn()
{
this.setTitle("HR SYSTEM LOGIN SCREEN");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(100, 100, 308, 179);
JPanel contentPane = new JPanel();
this.getContentPane().add(contentPane);
JLabel userName = new JLabel("User Name");
contentPane.add(userName);
JLabel password = new JLabel("Password");
contentPane.add(password);
JFormattedTextField userText = new JFormattedTextField();
contentPane.add(userText);
JPasswordField passwordText = new JPasswordField();
contentPane.add(passwordText);
JButton signButton = new JButton("Sign In");
contentPane.add(signButton);
}
}