Search in sources :

Example 46 with JPasswordField

use of javax.swing.JPasswordField in project aerospike-client-java by aerospike.

the class GuiDisplay method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frmAerospikeExamples = new JFrame();
    frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
    frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmAerospikeExamples.pack();
    frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
    mainPanel = new JPanel();
    splitPane.setLeftComponent(mainPanel);
    mainPanel.setLayout(new BorderLayout(0, 0));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    runButton = new JButton("Run");
    runButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            consoleTextArea.setText("");
            run_selected_examples();
        }
    });
    buttonPanel.add(runButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    exitButton = new JButton("Quit");
    exitButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            Container Frame = exitButton.getParent();
            do {
                Frame = Frame.getParent();
            } while (!(Frame instanceof JFrame));
            ((JFrame) Frame).dispose();
        }
    });
    buttonPanel.add(exitButton);
    sourceTextPane = new JTextArea();
    sourceTextPane.setTabSize(2);
    sourceTextPane.setEditable(false);
    scrollPane = new JScrollPane(sourceTextPane);
    scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    scrollPane.setPreferredSize(new Dimension(600, 100));
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    connectionPanel = new JPanel();
    connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    lblServerHost = new JLabel("Server Host");
    connectionPanel.add(lblServerHost);
    seedHostTextField = new JTextField();
    seedHostTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.host = seedHostTextField.getText();
        }
    });
    connectionPanel.add(seedHostTextField);
    seedHostTextField.setColumns(10);
    lblPort = new JLabel("Port");
    connectionPanel.add(lblPort);
    portTextField = new JTextField();
    portTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent arg0) {
            String newValue = namespaceTextField.getText();
            if (newValue != null && newValue != "") {
                try {
                    params.port = Integer.parseInt(newValue);
                } catch (NumberFormatException ne) {
                // ne.printStackTrace();
                }
            }
        }
    });
    connectionPanel.add(portTextField);
    portTextField.setColumns(4);
    lblusername = new JLabel("User");
    connectionPanel.add(lblusername);
    usernameTextField = new JTextField();
    usernameTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = usernameTextField.getText();
        }
    });
    connectionPanel.add(usernameTextField);
    usernameTextField.setColumns(8);
    lblpassword = new JLabel("Password");
    connectionPanel.add(lblpassword);
    passwordTextField = new JPasswordField();
    passwordTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = new String(passwordTextField.getPassword());
        }
    });
    connectionPanel.add(passwordTextField);
    passwordTextField.setColumns(8);
    lblnameSpace = new JLabel("Namespace");
    connectionPanel.add(lblnameSpace);
    namespaceTextField = new JTextField();
    namespaceTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.namespace = namespaceTextField.getText();
        }
    });
    connectionPanel.add(namespaceTextField);
    namespaceTextField.setColumns(8);
    lblSet = new JLabel("Set");
    connectionPanel.add(lblSet);
    txtSetTextfield = new JTextField();
    txtSetTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.set = txtSetTextfield.getText();
        }
    });
    connectionPanel.add(txtSetTextfield);
    txtSetTextfield.setColumns(8);
    mainPanel.add(connectionPanel, BorderLayout.NORTH);
    examplePanel = new JPanel();
    examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
    exampleScrollPane = new JScrollPane(examplePanel);
    mainPanel.add(exampleScrollPane, BorderLayout.WEST);
    // init values
    seedHostTextField.setText(params.host);
    portTextField.setText(Integer.toString(params.port));
    namespaceTextField.setText(params.namespace);
    txtSetTextfield.setText(params.set);
    // int width = 785;
    int width = 1000;
    int height = 180;
    consoleTextArea = new JTextArea();
    consoleTextArea.setSize(new Dimension(width, height));
    consoleTextArea.setEditable(false);
    consoleScrollPane = new JScrollPane(consoleTextArea);
    consoleScrollPane.setPreferredSize(new Dimension(width, height));
    consoleScrollPane.setSize(new Dimension(width, height));
    splitPane.setRightComponent(consoleScrollPane);
    buttonGroup = new ButtonGroup();
    JRadioButton jrb;
    for (String example : Main.getAllExampleNames()) {
        jrb = new JRadioButton(example);
        jrb.setActionCommand(example);
        jrb.addActionListener(this);
        buttonGroup.add(jrb);
        examplePanel.add(jrb);
    }
    frmAerospikeExamples.pack();
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) KeyAdapter(java.awt.event.KeyAdapter) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) KeyEvent(java.awt.event.KeyEvent) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EtchedBorder(javax.swing.border.EtchedBorder) JPasswordField(javax.swing.JPasswordField) ButtonGroup(javax.swing.ButtonGroup) JSplitPane(javax.swing.JSplitPane)

Example 47 with JPasswordField

use of javax.swing.JPasswordField in project n2a by frothga.

the class ConnectionInfo method makePasswordField.

public JPasswordField makePasswordField(String value) {
    JPasswordField result = new JPasswordField(value, 20);
    result.addAncestorListener(new AncestorListener() {

        public void ancestorRemoved(AncestorEvent event) {
        }

        public void ancestorMoved(AncestorEvent event) {
        }

        public void ancestorAdded(AncestorEvent event) {
            result.requestFocusInWindow();
        }
    });
    return result;
}
Also used : JPasswordField(javax.swing.JPasswordField) AncestorListener(javax.swing.event.AncestorListener) AncestorEvent(javax.swing.event.AncestorEvent)

Example 48 with JPasswordField

use of javax.swing.JPasswordField in project n2a by frothga.

the class ConnectionInfo method promptKeyboardInteractive.

public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
    if (!connection.allowDialogs)
        return null;
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridx = 0;
    panel.add(new JLabel(instruction), gbc);
    gbc.gridy++;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    JTextField[] texts = new JTextField[prompt.length];
    for (int i = 0; i < prompt.length; i++) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = 0;
        gbc.weightx = 1;
        panel.add(new JLabel(prompt[i]), gbc);
        gbc.gridx = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weighty = 1;
        if (echo[i])
            texts[i] = new JTextField(20);
        else
            texts[i] = new JPasswordField(20);
        panel.add(texts[i], gbc);
        gbc.gridy++;
    }
    int result = JOptionPane.showConfirmDialog(MainFrame.instance, panel, destination + ": " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        String[] response = new String[prompt.length];
        for (int i = 0; i < prompt.length; i++) response[i] = texts[i].getText();
        return response;
    }
    connection.allowDialogs = false;
    // cancel
    return null;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 49 with JPasswordField

use of javax.swing.JPasswordField in project sldeditor by robward-scisys.

the class DatabaseConnector method createField.

/**
 * Creates the field.
 *
 * @param key the key
 * @param labelString the label string
 * @param addToAcceptList the add to accept list
 * @param encrypted the encrypted
 * @param isFilename the is filename
 */
private void createField(DatabaseConnectionField field) {
    int row = textFieldMap.size();
    int y = row * ROW_HEIGHT;
    JLabel label = new JLabel(Localisation.getField(DatabaseConnector.class, field.getFieldName()));
    label.setBounds(LABEL_X, y, LABEL_WIDTH, FIELD_HEIGHT);
    panel.add(label);
    JTextField textField = null;
    if (!field.isPassword()) {
        textField = new JTextField();
    } else {
        textField = new JPasswordField();
    }
    textField.setBounds(FIELD_X, y, FIELD_WIDTH, FIELD_HEIGHT);
    textFieldMap.put(field.getKey(), textField);
    panel.add(textField);
    if (!(field.isPassword() || field.isUsername())) {
        acceptFieldList.add(field.getKey());
    }
    if (field.isFilename()) {
        JButton button = new JButton("File");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                JFileChooser fileChooser = new JFileChooser();
                FileNameExtensionFilter fileExtensionFilter = field.getFileExtensionFilter();
                fileChooser.setFileFilter(fileExtensionFilter);
                File f = SLDEditorFile.getInstance().getSldEditorFile();
                if ((f != null) && f.exists()) {
                    fileChooser.setSelectedFile(f);
                }
                int result = fileChooser.showOpenDialog(panel);
                if (result == JFileChooser.APPROVE_OPTION) {
                    File selectedFile = fileChooser.getSelectedFile();
                    textFieldMap.get(field.getKey()).setText(selectedFile.getAbsolutePath());
                }
            }
        });
        button.setBounds(textField.getX() + textField.getWidth() + 5, y, BasePanel.WIDGET_BUTTON_WIDTH, FIELD_HEIGHT);
        panel.add(button);
    }
}
Also used : ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File)

Example 50 with JPasswordField

use of javax.swing.JPasswordField in project nhin-d by DirectProject.

the class ComponentCreation method createComponent.

/**
	 * Process the container pane to create different swing component as per the identifier given as parameter
	 * @param type This decide which component should be created
	 * @param labelData This is the value of a component/or can be used as title of the component
	 * @param flag This is used to make any check box or radio button selected
	 * @param c is a object of GridBagConstarins, and used to set any grid layout
	 * @param pane Container object to add component into this pane
	 * @param myButtonGroup used for radio or check boxes to group together
	 * @param gridx This is the x index integer value for the component inside the grid
	 * @param gridy This is the y index integer value for the component inside the grid
	 * @return void 
	 */
public void createComponent(String type, String lableData, boolean flag, GridBagConstraints c, Container pane, ButtonGroup myButtonGroup, int gridx, int gridy) {
    if (type.equalsIgnoreCase("RADIO")) {
        JRadioButton aButton = new JRadioButton(lableData, flag);
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(aButton, c);
        /*
			 * Button group to make the dynamic movement of screens
			 */
        TrustBundlePublisher ex = new TrustBundlePublisher();
        if (myButtonGroup != null) {
            myButtonGroup.add(aButton);
            if (lableData.equalsIgnoreCase("  Create Unsigned Trust Bundle")) {
                //UnSignedTrustBundle ex = new UnSignedTrustBundle();
                aButton.addActionListener(ex);
            } else if (lableData.equalsIgnoreCase("  Create Signed Trust Bundle")) {
                //SignedTrustBundle ex = new SignedTrustBundle();
                aButton.addActionListener(ex);
            } else {
                //ViewTrustBundle ex = new ViewTrustBundle();
                aButton.addActionListener(ex);
            }
        }
    } else if (type.equalsIgnoreCase("LABEL")) {
        JLabel label1 = new JLabel(lableData);
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(label1, c);
    } else if (type.equalsIgnoreCase("TEXT")) {
        JTextField field = new JTextField();
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(field, c);
    } else if (type.equalsIgnoreCase("PASSWORD")) {
        //JTextField field = new JTextField();
        JPasswordField passwordField = new JPasswordField(10);
        //passwordField.setActionCommand(OK);
        //passwordField.addActionListener(this);
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(passwordField, c);
    } else if (type.equalsIgnoreCase("BUTTON")) {
        JButton button = new JButton(lableData);
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(button, c);
        ButtonSelector create = new ButtonSelector(pane);
        button.addActionListener(create);
    } else if (type.equalsIgnoreCase("TEXTPANE")) {
        JTextPane jTextPane = new JTextPane();
        jTextPane.setEditable(false);
        jTextPane.setBackground(new Color(238, 238, 238));
        ;
        //jTextPane.setSize(55, 10);
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(jTextPane, c);
    } else if (type.equalsIgnoreCase("TEXTAREA")) {
        JTextArea jTextPane = new JTextArea(lableData);
        jTextPane.setEditable(false);
        jTextPane.setBackground(new Color(238, 238, 238));
        ;
        c.gridx = gridx;
        c.gridy = gridy;
        pane.add(jTextPane, c);
    }
}
Also used : JTextPane(javax.swing.JTextPane) JRadioButton(javax.swing.JRadioButton) JTextArea(javax.swing.JTextArea) JPasswordField(javax.swing.JPasswordField) Color(java.awt.Color) TrustBundlePublisher(org.nhindirect.trustbundle.ui.TrustBundlePublisher) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Aggregations

JPasswordField (javax.swing.JPasswordField)100 JLabel (javax.swing.JLabel)60 JPanel (javax.swing.JPanel)47 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)30 JButton (javax.swing.JButton)24 JCheckBox (javax.swing.JCheckBox)23 GridBagLayout (java.awt.GridBagLayout)22 GridBagConstraints (java.awt.GridBagConstraints)19 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)19 Insets (java.awt.Insets)18 Dimension (java.awt.Dimension)15 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 EmptyBorder (javax.swing.border.EmptyBorder)12 EtchedBorder (javax.swing.border.EtchedBorder)12 AbstractAction (javax.swing.AbstractAction)11 CompoundBorder (javax.swing.border.CompoundBorder)11 ItemEvent (java.awt.event.ItemEvent)7