Created
May 9, 2019 02:36
-
-
Save avinashseth/230b8b4039a9aa4e5214fd2a8ecb0b94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package guinow; | |
| import java.awt.EventQueue; | |
| import javax.swing.JFrame; | |
| import com.jgoodies.forms.layout.FormLayout; | |
| import com.jgoodies.forms.layout.ColumnSpec; | |
| import com.jgoodies.forms.layout.RowSpec; | |
| import javax.swing.JMenuBar; | |
| import javax.swing.JMenu; | |
| import javax.swing.JMenuItem; | |
| import com.jgoodies.forms.layout.FormSpecs; | |
| import javax.swing.JSpinner; | |
| import javax.swing.JProgressBar; | |
| import javax.swing.JSlider; | |
| import java.awt.CardLayout; | |
| import javax.swing.JLabel; | |
| import javax.swing.JCheckBox; | |
| import javax.swing.JEditorPane; | |
| import javax.swing.JInternalFrame; | |
| import javax.swing.JTable; | |
| import com.jgoodies.forms.factories.DefaultComponentFactory; | |
| import javax.swing.JToolBar; | |
| import java.awt.BorderLayout; | |
| import javax.swing.Box; | |
| import javax.swing.JToggleButton; | |
| import javax.swing.JRadioButtonMenuItem; | |
| import javax.swing.SpringLayout; | |
| import java.awt.Cursor; | |
| import java.awt.Font; | |
| import javax.swing.JTextField; | |
| import javax.swing.JPasswordField; | |
| import javax.swing.JButton; | |
| import java.awt.event.ActionListener; | |
| import java.awt.event.ActionEvent; | |
| public class RegisterWindow { | |
| private JFrame frame; | |
| private JTextField textField; | |
| private JPasswordField passwordField; | |
| /** | |
| * Launch the application. | |
| */ | |
| public static void main(String[] args) { | |
| EventQueue.invokeLater(new Runnable() { | |
| public void run() { | |
| try { | |
| RegisterWindow window = new RegisterWindow(); | |
| window.frame.setVisible(true); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| }); | |
| } | |
| /** | |
| * Create the application. | |
| */ | |
| public RegisterWindow() { | |
| initialize(); | |
| } | |
| /** | |
| * Initialize the contents of the frame. | |
| */ | |
| private void initialize() { | |
| frame = new JFrame(); | |
| frame.setBounds(100, 100, 450, 300); | |
| frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
| SpringLayout springLayout = new SpringLayout(); | |
| frame.getContentPane().setLayout(springLayout); | |
| JLabel lblUsername = new JLabel("Username"); | |
| lblUsername.setFont(new Font("Source Sans Pro Semibold", Font.PLAIN, 10)); | |
| lblUsername.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); | |
| springLayout.putConstraint(SpringLayout.NORTH, lblUsername, 35, SpringLayout.NORTH, frame.getContentPane()); | |
| springLayout.putConstraint(SpringLayout.WEST, lblUsername, 50, SpringLayout.WEST, frame.getContentPane()); | |
| frame.getContentPane().add(lblUsername); | |
| textField = new JTextField(); | |
| springLayout.putConstraint(SpringLayout.NORTH, textField, 6, SpringLayout.SOUTH, lblUsername); | |
| springLayout.putConstraint(SpringLayout.WEST, textField, 47, SpringLayout.WEST, frame.getContentPane()); | |
| frame.getContentPane().add(textField); | |
| textField.setColumns(10); | |
| JLabel lblPassword = new JLabel("Password"); | |
| springLayout.putConstraint(SpringLayout.NORTH, lblPassword, 6, SpringLayout.SOUTH, textField); | |
| springLayout.putConstraint(SpringLayout.WEST, lblPassword, 0, SpringLayout.WEST, lblUsername); | |
| frame.getContentPane().add(lblPassword); | |
| passwordField = new JPasswordField(); | |
| springLayout.putConstraint(SpringLayout.NORTH, passwordField, 6, SpringLayout.SOUTH, lblPassword); | |
| springLayout.putConstraint(SpringLayout.WEST, passwordField, 50, SpringLayout.WEST, frame.getContentPane()); | |
| springLayout.putConstraint(SpringLayout.EAST, passwordField, 3, SpringLayout.EAST, textField); | |
| frame.getContentPane().add(passwordField); | |
| JButton btnLogin = new JButton("Login"); | |
| springLayout.putConstraint(SpringLayout.WEST, btnLogin, 165, SpringLayout.WEST, frame.getContentPane()); | |
| springLayout.putConstraint(SpringLayout.SOUTH, btnLogin, -57, SpringLayout.SOUTH, frame.getContentPane()); | |
| frame.getContentPane().add(btnLogin); | |
| JCheckBox chckbxRememberMe = new JCheckBox("Remember me?"); | |
| springLayout.putConstraint(SpringLayout.WEST, chckbxRememberMe, 146, SpringLayout.WEST, frame.getContentPane()); | |
| springLayout.putConstraint(SpringLayout.SOUTH, chckbxRememberMe, -23, SpringLayout.NORTH, btnLogin); | |
| frame.getContentPane().add(chckbxRememberMe); | |
| JLabel lblResult = new JLabel("New label"); | |
| springLayout.putConstraint(SpringLayout.WEST, lblResult, 0, SpringLayout.WEST, lblUsername); | |
| springLayout.putConstraint(SpringLayout.SOUTH, lblResult, -28, SpringLayout.SOUTH, frame.getContentPane()); | |
| frame.getContentPane().add(lblResult); | |
| btnLogin.addActionListener(new ActionListener() { | |
| public void actionPerformed(ActionEvent e) { | |
| textField.getText(); | |
| passwordField.getText(); | |
| chckbxRememberMe.isSelected(); | |
| lblResult.setText("Username is " + textField.getText() + " password is " + passwordField.getText() + " " + chckbxRememberMe.isSelected()); | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment