Example usage for javax.swing JPasswordField JPasswordField

List of usage examples for javax.swing JPasswordField JPasswordField

Introduction

In this page you can find the example usage for javax.swing JPasswordField JPasswordField.

Prototype

public JPasswordField() 

Source Link

Document

Constructs a new JPasswordField, with a default document, null starting text string, and 0 column width.

Usage

From source file:ActionsMenuBar.java

public static void main(String args[]) {
    final JFrame frame = new JFrame("TextAction Usage");
    Container contentPane = frame.getContentPane();
    final JScrollPane scrollPane = new JScrollPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);

    final JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);/*from www .j  a v a  2  s .c o m*/

    ActionListener actionListener = new ActionListener() {
        JTextComponent component;

        public void actionPerformed(ActionEvent actionEvent) {
            // Determine which component selected
            String command = actionEvent.getActionCommand();
            if (command.equals("JTextField")) {
                component = new JTextField();
            } else if (command.equals("JPasswordField")) {
                component = new JPasswordField();
            } else if (command.equals("JTextArea")) {
                component = new JTextArea();
            } else if (command.equals("JTextPane")) {
                component = new JTextPane();
            } else {
                component = new JEditorPane();
            }
            scrollPane.setViewportView(component);
            // Process action list
            Action actions[] = component.getActions();
            menuBar.removeAll();
            menuBar.revalidate();
            JMenu menu = null;
            for (int i = 0, n = actions.length; i < n; i++) {
                if ((i % 10) == 0) {
                    menu = new JMenu("From " + i);
                    menuBar.add(menu);
                }
                menu.add(actions[i]);
            }
            menuBar.revalidate();
        }
    };

    String components[] = { "JTextField", "JPasswordField", "JTextArea", "JTextPane", "JEditorPane" };
    final Container componentsContainer = RadioButtonUtils.createRadioButtonGrouping(components,
            "Pick to List Actions", actionListener);
    contentPane.add(componentsContainer, BorderLayout.WEST);

    frame.setSize(400, 300);
    frame.setVisible(true);
}

From source file:Main.java

public static JPasswordField createStandardSecretTextField() {
    JPasswordField pf = new JPasswordField();
    return pf;
}

From source file:TextComponentTest.java

public TextComponentFrame() {
    setTitle("TextComponentTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    final JTextField textField = new JTextField();
    final JPasswordField passwordField = new JPasswordField();

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new GridLayout(2, 2));
    northPanel.add(new JLabel("User name: ", SwingConstants.RIGHT));
    northPanel.add(textField);/*from w w w .  ja v  a2s.  c  o m*/
    northPanel.add(new JLabel("Password: ", SwingConstants.RIGHT));
    northPanel.add(passwordField);

    add(northPanel, BorderLayout.NORTH);

    final JTextArea textArea = new JTextArea(8, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);

    add(scrollPane, BorderLayout.CENTER);

    // add button to append text into the text area

    JPanel southPanel = new JPanel();

    JButton insertButton = new JButton("Insert");
    southPanel.add(insertButton);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            textArea.append("User name: " + textField.getText() + " Password: "
                    + new String(passwordField.getPassword()) + "\n");
        }
    });

    add(southPanel, BorderLayout.SOUTH);

    // add a text area with scroll bars

}

From source file:com.gs.obevo.util.inputreader.DialogInputReader.java

@Override
public String readPassword(String promptMessage) {
    final JPasswordField jpf = new JPasswordField();
    JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = jop.createDialog(promptMessage);
    dialog.addComponentListener(new ComponentAdapter() {
        @Override/*from  w w w.  j a  v  a  2  s. co m*/
        public void componentShown(ComponentEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    jpf.requestFocusInWindow();
                }
            });
        }
    });
    dialog.setVisible(true);
    int result = (Integer) jop.getValue();
    dialog.dispose();
    String password = null;
    if (result == JOptionPane.OK_OPTION) {
        password = new String(jpf.getPassword());
    }
    if (StringUtils.isEmpty(password)) {
        return null;
    } else {
        return password;
    }
}

From source file:com.cactus.ClientLoginGUI.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w w w . j a  v a  2 s  . c  o  m
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    this.pack();
    this.setLocationRelativeTo(null);

    Username_TextField = new JTextField();
    Password_TextField = new JPasswordField();
    Username_Label = new JLabel();
    Password_label = new JLabel();
    Login_Button = new JButton();
    Register_Button = new JButton();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    Username_TextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Username_TextFieldActionPerformed(evt);
        }
    });

    Password_TextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Password_TextFieldActionPerformed(evt);
        }
    });

    Username_Label.setText("Username:");

    Password_label.setText("Password:");

    Login_Button.setText("Login");
    Login_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Login_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    Register_Button.setText("Register");
    Register_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Register_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    javax.swing.GroupLayout layout = new GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addGap(101)
            .addGroup(layout.createParallelGroup(Alignment.LEADING, false).addComponent(Password_label)
                    .addComponent(Username_TextField)
                    .addComponent(Password_TextField, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup().addComponent(Register_Button)
                            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(Login_Button))
                    .addComponent(Username_Label, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE))
            .addContainerGap(128, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addGap(71).addComponent(Username_Label)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Username_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(27).addComponent(Password_label).addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Password_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(33).addGroup(layout.createParallelGroup(Alignment.BASELINE)
                            .addComponent(Register_Button).addComponent(Login_Button))
                    .addContainerGap(48, Short.MAX_VALUE)));
    getContentPane().setLayout(layout);

    pack();
}

From source file:com.view.AdminWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from  ww w. ja  v  a 2s .c om*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jTabbedPane1 = new javax.swing.JTabbedPane();
    AddPortfMan = new javax.swing.JPanel();
    CreatePMButton = new java.awt.Button();
    CreatePortfolioNameText = new javax.swing.JTextField();
    CreatePortfolioUsernameText = new javax.swing.JTextField();
    CreatePortfolioPasswordText = new JPasswordField();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jPanel2 = new javax.swing.JPanel();
    label4 = new java.awt.Label();
    jLabel4 = new javax.swing.JLabel();
    CreatePortfolioConfirmPasswordText = new JPasswordField();
    AddTrader = new javax.swing.JPanel();
    createTraderButton = new java.awt.Button();
    CreateTraderNameText = new javax.swing.JTextField();
    CreateTraderUsernameText = new javax.swing.JTextField();
    CreateTraderPasswordText = new JPasswordField();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();
    label5 = new java.awt.Label();
    CreateTraderConfirmPasswordText = new JPasswordField();
    jLabel5 = new javax.swing.JLabel();
    AddBroker = new javax.swing.JPanel();
    createBrokerButton = new java.awt.Button();
    CreateBrokerNameText = new javax.swing.JTextField();
    CreateBrokerEmailText = new javax.swing.JTextField();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jPanel4 = new javax.swing.JPanel();
    label6 = new java.awt.Label();
    ChangePassword = new javax.swing.JPanel();
    label2 = new java.awt.Label();
    label3 = new java.awt.Label();
    label7 = new java.awt.Label();
    submitButton = new java.awt.Button();
    jPanel5 = new javax.swing.JPanel();
    label8 = new java.awt.Label();
    NewPassText = new JPasswordField();
    ConfirmPassText = new JPasswordField();
    OldPassText = new JPasswordField();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(new java.awt.GridBagLayout());

    CreatePMButton.setBackground(new java.awt.Color(51, 51, 51));
    CreatePMButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
    CreatePMButton.setForeground(new java.awt.Color(240, 240, 240));
    CreatePMButton.setLabel("Create Portfolio Manager");
    CreatePMButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            CreatePMButtonActionPerformed(evt);
        }
    });

    CreatePortfolioNameText.setBackground(new java.awt.Color(51, 51, 51));
    CreatePortfolioNameText.setForeground(new java.awt.Color(255, 255, 255));
    CreatePortfolioNameText.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            CreatePortfolioNameTextActionPerformed(evt);
        }
    });

    CreatePortfolioUsernameText.setBackground(new java.awt.Color(51, 51, 51));
    CreatePortfolioUsernameText.setForeground(new java.awt.Color(255, 255, 255));

    CreatePortfolioPasswordText.setBackground(new java.awt.Color(51, 51, 51));
    CreatePortfolioPasswordText.setForeground(new java.awt.Color(255, 255, 255));

    jLabel1.setText("Name:");

    jLabel2.setText("Username:");

    jLabel3.setText("Temporary Password:");

    jPanel2.setBackground(new java.awt.Color(51, 51, 51));

    label4.setAlignment(java.awt.Label.CENTER);
    label4.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
    label4.setForeground(new java.awt.Color(240, 240, 240));
    label4.setText("Create A New Portfolio Manager");

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup().addGap(41, 41, 41)
                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(51, Short.MAX_VALUE))));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 52, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));

    jLabel4.setText("Confirm Password:");

    CreatePortfolioConfirmPasswordText.setBackground(new java.awt.Color(51, 51, 51));
    CreatePortfolioConfirmPasswordText.setForeground(new java.awt.Color(255, 255, 255));

    javax.swing.GroupLayout AddPortfManLayout = new javax.swing.GroupLayout(AddPortfMan);
    AddPortfMan.setLayout(AddPortfManLayout);
    AddPortfManLayout.setHorizontalGroup(AddPortfManLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addGroup(AddPortfManLayout.createSequentialGroup().addGap(42, 42, 42)
                    .addGroup(AddPortfManLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(AddPortfManLayout.createSequentialGroup().addGroup(AddPortfManLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(CreatePortfolioConfirmPasswordText,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60,
                                            Short.MAX_VALUE)
                                    .addComponent(
                                            CreatePMButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(AddPortfManLayout.createSequentialGroup().addGroup(AddPortfManLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(AddPortfManLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                    false)
                                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(CreatePortfolioPasswordText,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(AddPortfManLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                    false)
                                            .addComponent(jLabel2).addComponent(CreatePortfolioUsernameText))
                                    .addComponent(jLabel1).addComponent(CreatePortfolioNameText,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(0, 0, Short.MAX_VALUE)))
                    .addContainerGap()));
    AddPortfManLayout.setVerticalGroup(AddPortfManLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AddPortfManLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreatePortfolioNameText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreatePortfolioUsernameText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreatePortfolioPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(AddPortfManLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(AddPortfManLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(CreatePMButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap())
                            .addGroup(AddPortfManLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel4)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(CreatePortfolioConfirmPasswordText,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(44, Short.MAX_VALUE)))));

    jTabbedPane1.addTab("Add Portfolio Manager", AddPortfMan);

    createTraderButton.setBackground(new java.awt.Color(51, 51, 51));
    createTraderButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
    createTraderButton.setForeground(new java.awt.Color(240, 240, 240));
    createTraderButton.setLabel("Create Trader");
    createTraderButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            createTraderButtonActionPerformed(evt);
        }
    });

    CreateTraderNameText.setBackground(new java.awt.Color(51, 51, 51));
    CreateTraderNameText.setForeground(new java.awt.Color(255, 255, 255));

    CreateTraderUsernameText.setBackground(new java.awt.Color(51, 51, 51));
    CreateTraderUsernameText.setForeground(new java.awt.Color(255, 255, 255));

    CreateTraderPasswordText.setBackground(new java.awt.Color(51, 51, 51));
    CreateTraderPasswordText.setForeground(new java.awt.Color(255, 255, 255));

    jLabel9.setText("Name:");

    jLabel10.setText("Username:");

    jLabel11.setText("Temporary Password:");

    jPanel3.setBackground(new java.awt.Color(51, 51, 51));

    label5.setAlignment(java.awt.Label.CENTER);
    label5.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
    label5.setForeground(new java.awt.Color(240, 240, 240));
    label5.setText("Create A New Trader");

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup().addGap(41, 41, 41)
                            .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(51, Short.MAX_VALUE))));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 52, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));

    CreateTraderConfirmPasswordText.setBackground(new java.awt.Color(51, 51, 51));
    CreateTraderConfirmPasswordText.setForeground(new java.awt.Color(255, 255, 255));

    jLabel5.setText("Confirm Password:");

    javax.swing.GroupLayout AddTraderLayout = new javax.swing.GroupLayout(AddTrader);
    AddTrader.setLayout(AddTraderLayout);
    AddTraderLayout.setHorizontalGroup(AddTraderLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addGroup(AddTraderLayout.createSequentialGroup().addGap(42, 42, 42)
                    .addGroup(AddTraderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(CreateTraderNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(AddTraderLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel10).addComponent(CreateTraderUsernameText))
                            .addGroup(AddTraderLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(CreateTraderPasswordText))
                            .addGroup(AddTraderLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(CreateTraderConfirmPasswordText,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(228, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AddTraderLayout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(createTraderButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(50, 50, 50)));
    AddTraderLayout.setVerticalGroup(AddTraderLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AddTraderLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(jLabel9)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreateTraderNameText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel10).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreateTraderUsernameText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreateTraderPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreateTraderConfirmPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(createTraderButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

    jTabbedPane1.addTab("Add Trader", AddTrader);

    createBrokerButton.setBackground(new java.awt.Color(51, 51, 51));
    createBrokerButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
    createBrokerButton.setForeground(new java.awt.Color(240, 240, 240));
    createBrokerButton.setLabel("Create Broker");
    createBrokerButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            createBrokerButtonActionPerformed(evt);
        }
    });

    CreateBrokerNameText.setBackground(new java.awt.Color(51, 51, 51));
    CreateBrokerNameText.setForeground(new java.awt.Color(255, 255, 255));

    CreateBrokerEmailText.setBackground(new java.awt.Color(51, 51, 51));
    CreateBrokerEmailText.setForeground(new java.awt.Color(255, 255, 255));

    jLabel13.setText("Name:");

    jLabel14.setText("Email Address:");

    jPanel4.setBackground(new java.awt.Color(51, 51, 51));

    label6.setAlignment(java.awt.Label.CENTER);
    label6.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
    label6.setForeground(new java.awt.Color(240, 240, 240));
    label6.setText("Create A New Broker");

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup().addGap(41, 41, 41)
                            .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(51, Short.MAX_VALUE))));
    jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 52, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                            .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));

    javax.swing.GroupLayout AddBrokerLayout = new javax.swing.GroupLayout(AddBroker);
    AddBroker.setLayout(AddBrokerLayout);
    AddBrokerLayout.setHorizontalGroup(AddBrokerLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AddBrokerLayout.createSequentialGroup().addGroup(AddBrokerLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AddBrokerLayout.createSequentialGroup().addGap(149, 149, 149)
                            .addGroup(AddBrokerLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel14).addComponent(jLabel13)
                                    .addComponent(CreateBrokerNameText, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            89, Short.MAX_VALUE)
                                    .addComponent(CreateBrokerEmailText))
                            .addGap(0, 127, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            AddBrokerLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(
                                    createBrokerButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    AddBrokerLayout.setVerticalGroup(AddBrokerLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AddBrokerLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(76, 76, 76).addComponent(jLabel13).addGap(7, 7, 7)
                    .addComponent(CreateBrokerNameText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(jLabel14)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(CreateBrokerEmailText, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(createBrokerButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

    jTabbedPane1.addTab("Add Broker", AddBroker);

    label2.setText("Old Password:");

    label3.setText("New Password:");

    label7.setText("Confirm Password:");

    submitButton.setBackground(new java.awt.Color(51, 51, 51));
    submitButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
    submitButton.setForeground(new java.awt.Color(240, 240, 240));
    submitButton.setLabel("Submit");
    submitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            submitButtonActionPerformed(evt);
        }
    });

    jPanel5.setBackground(new java.awt.Color(51, 51, 51));

    label8.setAlignment(java.awt.Label.CENTER);
    label8.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
    label8.setForeground(new java.awt.Color(240, 240, 240));
    label8.setText("Change Password");

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup().addGap(41, 41, 41)
                    .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                    .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    NewPassText.setBackground(new java.awt.Color(51, 51, 51));
    NewPassText.setForeground(new java.awt.Color(255, 255, 255));

    ConfirmPassText.setBackground(new java.awt.Color(51, 51, 51));
    ConfirmPassText.setForeground(new java.awt.Color(255, 255, 255));

    OldPassText.setBackground(new java.awt.Color(51, 51, 51));
    OldPassText.setForeground(new java.awt.Color(255, 255, 255));

    javax.swing.GroupLayout ChangePasswordLayout = new javax.swing.GroupLayout(ChangePassword);
    ChangePassword.setLayout(ChangePasswordLayout);
    ChangePasswordLayout.setHorizontalGroup(ChangePasswordLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(ChangePasswordLayout.createSequentialGroup().addGap(72, 72, 72)
                    .addGroup(ChangePasswordLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(submitButton, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(ChangePasswordLayout.createSequentialGroup()
                                    .addGroup(ChangePasswordLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(ChangePasswordLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(NewPassText)
                                            .addGroup(ChangePasswordLayout.createSequentialGroup()
                                                    .addComponent(ConfirmPassText,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(0, 1, Short.MAX_VALUE))
                                            .addComponent(OldPassText))))
                    .addContainerGap(77, Short.MAX_VALUE)));
    ChangePasswordLayout.setVerticalGroup(ChangePasswordLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ChangePasswordLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(27, 27, 27)
                    .addGroup(
                            ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(OldPassText, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(
                            ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(NewPassText, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(
                            ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(ConfirmPassText, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(34, 34, 34)
                    .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(74, Short.MAX_VALUE)));

    jTabbedPane1.addTab("Change Password", ChangePassword);

    getContentPane().add(jTabbedPane1, new java.awt.GridBagConstraints());

    pack();
}

From source file:com.cactus.ClientRegisterGUI.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from w  w w.j  av  a 2  s  .  c o  m*/
 */

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    this.pack();
    this.setLocationRelativeTo(null);

    Username_TextField = new JTextField();
    Email_TextField = new JTextField();
    Email_Confirm_TextField = new JTextField();
    Password_TextField = new JPasswordField();
    Confirm_Password_TextField = new JPasswordField();
    Username_Label = new JLabel();
    Email_Label = new JLabel();
    Email_Confirm_Label = new JLabel();
    Password_Label = new JLabel();
    Confirm_Password_Label = new JLabel();
    Register_Button = new JButton();
    Cancel_Button = new JButton();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    Email_TextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Email_TextFieldActionPerformed(evt);
        }
    });

    Username_Label.setText("Username:");
    Email_Label.setText("Email:");
    Email_Confirm_Label.setText("Confirm Email:");
    Password_Label.setText("Password:");
    Confirm_Password_Label.setText("Confirm Password:");

    Register_Button.setText("Register");
    Register_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Register_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    Cancel_Button.setText("Cancel");
    Cancel_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Cancel_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    javax.swing.GroupLayout layout = new GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addGap(67)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addComponent(Confirm_Password_Label)
                            .addContainerGap())
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(Email_Confirm_Label)
                                    .addContainerGap())
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addComponent(Email_Label)
                                            .addContainerGap())
                                    .addGroup(layout.createSequentialGroup().addComponent(Password_Label)
                                            .addContainerGap())
                                    .addGroup(layout.createSequentialGroup().addGroup(layout
                                            .createParallelGroup(Alignment.LEADING)
                                            .addComponent(Password_TextField, GroupLayout.DEFAULT_SIZE, 250,
                                                    Short.MAX_VALUE)
                                            .addComponent(Confirm_Password_TextField, GroupLayout.DEFAULT_SIZE,
                                                    250, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup().addComponent(Cancel_Button)
                                                    .addPreferredGap(ComponentPlacement.RELATED, 112,
                                                            Short.MAX_VALUE)
                                                    .addComponent(Register_Button))
                                            .addComponent(Username_Label)
                                            .addComponent(Username_TextField, 250, 250, Short.MAX_VALUE)
                                            .addComponent(Email_TextField, GroupLayout.DEFAULT_SIZE, 250,
                                                    Short.MAX_VALUE)
                                            .addComponent(Email_Confirm_TextField, GroupLayout.DEFAULT_SIZE,
                                                    250, Short.MAX_VALUE))
                                            .addGap(83)))))));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(Username_Label)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Username_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Email_Label)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Email_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Email_Confirm_Label).addGap(10)
                    .addComponent(Email_Confirm_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(Password_Label)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(Password_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Confirm_Password_Label)
                    .addGap(11)
                    .addComponent(Confirm_Password_TextField, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(18).addGroup(layout.createParallelGroup(Alignment.BASELINE)
                            .addComponent(Cancel_Button).addComponent(Register_Button))
                    .addContainerGap(26, Short.MAX_VALUE)));
    getContentPane().setLayout(layout);

    pack();
}

From source file:com.sun.jersey.client.apache.config.DefaultCredentialsProvider.java

public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy)
        throws CredentialsNotAvailableException {
    if (scheme == null) {
        return null;
    }/*from ww  w  .ja  v a 2 s .  c om*/

    try {
        JTextField userField = new JTextField();
        JPasswordField passwordField = new JPasswordField();
        int response;

        if (scheme instanceof NTLMScheme) {
            JTextField domainField = new JTextField();
            Object[] msg = { host + ":" + port + " requires Windows authentication", "Domain", domainField,
                    "User Name", userField, "Password", passwordField };
            response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION);

            if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) {
                throw new CredentialsNotAvailableException("User cancled windows authentication.");
            }

            return new NTCredentials(userField.getText(), new String(passwordField.getPassword()), host,
                    domainField.getText());

        } else if (scheme instanceof RFC2617Scheme) {
            Object[] msg = {
                    host + ":" + port + " requires authentication with the realm '" + scheme.getRealm() + "'",
                    "User Name", userField, "Password", passwordField };

            response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION);

            if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) {
                throw new CredentialsNotAvailableException("User cancled windows authentication.");
            }

            return new UsernamePasswordCredentials(userField.getText(),
                    new String(passwordField.getPassword()));

        } else {

            throw new CredentialsNotAvailableException(
                    "Unsupported authentication scheme: " + scheme.getSchemeName());

        }
    } catch (IOException ioe) {

        throw new CredentialsNotAvailableException(ioe.getMessage(), ioe);

    }
}

From source file:gov.nih.nci.nbia.StandaloneDM.java

private JPanel constructLoginPanel() {
    JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(null);/*  w  w  w .ja  v a2 s  .  co m*/

    JLabel lblNewLabel_2 = new JLabel();
    lblNewLabel_2.setBounds(20, 11, 100, 100);
    contentPane.add(lblNewLabel_2);
    ImageIcon iconLogo = new ImageIcon("Images/global.logo");
    lblNewLabel_2.setIcon(iconLogo);
    statusLbl = new JLabel(
            "<html>Some or all of the images you are about to download are from<br>private collection(s). Please log in first.</html>");
    contentPane.add(statusLbl);
    statusLbl.setBounds(110, 11, 500, 42);
    JLabel lblNewLabel = new JLabel("User Name");
    contentPane.add(lblNewLabel);
    lblNewLabel.setBounds(110, 79, 77, 31);

    userNameFld = new JTextField();
    contentPane.add(userNameFld);
    userNameFld.setBounds(187, 75, 333, 36);
    userNameFld.setColumns(10);

    JButton submitBtn = new JButton(SubmitBtnLbl);
    submitBtn.addActionListener(new BtnListener());
    contentPane.add(submitBtn);
    submitBtn.setBounds(249, 200, 139, 36);

    passwdFld = new JPasswordField();
    contentPane.add(passwdFld);
    passwdFld.setBounds(187, 129, 333, 36);

    userNameFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            passwdFld.requestFocus();
        }
    });

    passwdFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                statusLbl.setText("Please enter a valid user name and password.");
                statusLbl.setForeground(Color.red);
            } else
                submitUserCredential(userId, password);
        }
    });

    JLabel lblNewLabel_1 = new JLabel("Password");
    contentPane.add(lblNewLabel_1);
    lblNewLabel_1.setBounds(110, 129, 77, 36);

    return contentPane;
}

From source file:com.haulmont.cuba.desktop.LoginDialog.java

protected Container createContentPane() {
    MigLayout layout = new MigLayout("fillx, insets dialog", "[right][]");
    JPanel panel = new JPanel(layout);

    panel.add(new JLabel(messages.getMainMessage("loginWindow.loginField", resolvedLocale)));

    nameField = new JTextField();
    passwordField = new JPasswordField();

    String defaultName = desktopConfig.getLoginDialogDefaultUser();
    String lastLogin = loginProperties.loadLastLogin();
    if (!StringUtils.isBlank(lastLogin)) {
        nameField.setText(lastLogin);//  w  w w  . j  av  a2  s .  c  o m
        SwingUtilities.invokeLater(() -> passwordField.requestFocus());
    } else if (!StringUtils.isBlank(defaultName)) {
        nameField.setText(defaultName);
    }

    panel.add(nameField, "width 150!, wrap");

    panel.add(new JLabel(messages.getMainMessage("loginWindow.passwordField", resolvedLocale)));
    String defaultPassword = desktopConfig.getLoginDialogDefaultPassword();
    if (!StringUtils.isBlank(defaultPassword))
        passwordField.setText(defaultPassword);
    panel.add(passwordField, "width 150!, wrap");

    Configuration configuration = AppBeans.get(Configuration.NAME);

    localeCombo = new JComboBox<>();
    initLocales(localeCombo);
    if (configuration.getConfig(GlobalConfig.class).getLocaleSelectVisible()) {
        panel.add(new JLabel(messages.getMainMessage("loginWindow.localesSelect", resolvedLocale)));
        panel.add(localeCombo, "width 150!, wrap");
    }

    loginBtn = new JButton(messages.getMainMessage("loginWindow.okButton", resolvedLocale));
    loginBtn.setIcon(App.getInstance().getResources().getIcon("icons/ok.png"));
    loginBtn.addActionListener(e -> doLogin());
    DesktopComponentsHelper.adjustSize(loginBtn);
    panel.add(loginBtn, "span, align center");

    getRootPane().setDefaultButton(loginBtn);

    assignTestIdsIfNeeded(panel);

    return panel;
}