Search in sources :

Example 6 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 7 with JPasswordField

use of javax.swing.JPasswordField in project jmeter by apache.

the class MailerVisualizer method createSmtpSettings.

private JPanel createSmtpSettings() {
    JPanel settingsPane = new JPanel(new BorderLayout());
    settingsPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("mailer_title_smtpserver")));
    JPanel hostPane = new JPanel(new BorderLayout());
    hostPane.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    JPanel smtpHostPane = new JPanel(new BorderLayout());
    // $NON-NLS-1$
    smtpHostPane.add(new JLabel(JMeterUtils.getResString("mailer_host")), BorderLayout.WEST);
    smtpHostField = new JTextField(10);
    smtpHostField.setEditable(true);
    smtpHostPane.add(smtpHostField, BorderLayout.CENTER);
    smtpHostPane.add(Box.createRigidArea(new Dimension(5, 0)), BorderLayout.EAST);
    hostPane.add(smtpHostPane, BorderLayout.CENTER);
    JPanel smtpPortPane = new JPanel(new BorderLayout());
    // $NON-NLS-1$
    smtpPortPane.add(new JLabel(JMeterUtils.getResString("mailer_port")), BorderLayout.WEST);
    smtpPortField = new JTextField(10);
    smtpPortField.setEditable(true);
    smtpPortPane.add(smtpPortField, BorderLayout.CENTER);
    hostPane.add(smtpPortPane, BorderLayout.EAST);
    JPanel authPane = new JPanel(new BorderLayout());
    hostPane.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    JPanel smtpLoginPane = new JPanel(new BorderLayout());
    // $NON-NLS-1$
    smtpLoginPane.add(new JLabel(JMeterUtils.getResString("mailer_login")), BorderLayout.WEST);
    smtpLoginField = new JTextField(10);
    smtpLoginField.setEditable(true);
    smtpLoginPane.add(smtpLoginField, BorderLayout.CENTER);
    smtpLoginPane.add(Box.createRigidArea(new Dimension(5, 0)), BorderLayout.EAST);
    authPane.add(smtpLoginPane, BorderLayout.CENTER);
    JPanel smtpPasswordPane = new JPanel(new BorderLayout());
    // $NON-NLS-1$
    smtpPasswordPane.add(new JLabel(JMeterUtils.getResString("mailer_password")), BorderLayout.WEST);
    smtpPasswordField = new JPasswordField(10);
    smtpPasswordField.setEditable(true);
    smtpPasswordPane.add(smtpPasswordField, BorderLayout.CENTER);
    smtpPasswordPane.add(Box.createRigidArea(new Dimension(5, 0)), BorderLayout.EAST);
    authPane.add(smtpPasswordPane, BorderLayout.EAST);
    JPanel authTypePane = new JPanel(new BorderLayout());
    // $NON-NLS-1$
    authTypePane.add(new JLabel(JMeterUtils.getResString("mailer_connection_security")), BorderLayout.WEST);
    authTypeCombo = new JComboBox<>(new String[] { MailerModel.MailAuthType.NONE.toString(), MailerModel.MailAuthType.SSL.toString(), MailerModel.MailAuthType.TLS.toString() });
    // $NON-NLS-1$
    authTypeCombo.setFont(new Font("SansSerif", Font.PLAIN, 10));
    authTypePane.add(authTypeCombo, BorderLayout.CENTER);
    JPanel credPane = new JPanel(new BorderLayout());
    credPane.add(authPane, BorderLayout.CENTER);
    credPane.add(authTypePane, BorderLayout.EAST);
    settingsPane.add(hostPane, BorderLayout.NORTH);
    settingsPane.add(credPane, BorderLayout.CENTER);
    return settingsPane;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) Font(java.awt.Font)

Example 8 with JPasswordField

use of javax.swing.JPasswordField in project jmeter by apache.

the class SmtpPanel method initComponents.

/**
     * Main method of class, builds all gui-components for SMTP-sampler.
     */
private void initComponents() {
    // $NON-NLS-1$
    jlAddressReplyTo = new JLabel(JMeterUtils.getResString("smtp_replyto"));
    // $NON-NLS-1$
    jlAddressFrom = new JLabel(JMeterUtils.getResString("smtp_from"));
    // $NON-NLS-1$
    jlAddressTo = new JLabel(JMeterUtils.getResString("smtp_to"));
    // $NON-NLS-1$
    jlAddressToCC = new JLabel(JMeterUtils.getResString("smtp_cc"));
    // $NON-NLS-1$
    jlAddressToBCC = new JLabel(JMeterUtils.getResString("smtp_bcc"));
    // $NON-NLS-1$
    jlMailServerPort = new JLabel(JMeterUtils.getResString("smtp_server_port"));
    // $NON-NLS-1$
    jlMailServer = new JLabel(JMeterUtils.getResString("smtp_server"));
    // $NON-NLS-1$
    jlMailServerTimeout = new JLabel(JMeterUtils.getResString("smtp_server_timeout"));
    // $NON-NLS-1$
    jlMailServerConnectionTimeout = new JLabel(JMeterUtils.getResString("smtp_server_connection_timeout"));
    // $NON-NLS-1$
    jlAttachFile = new JLabel(JMeterUtils.getResString("smtp_attach_file"));
    // $NON-NLS-1$
    jlDutPortStandard = new JLabel(JMeterUtils.getResString("smtp_default_port"));
    // $NON-NLS-1$
    jlUsername = new JLabel(JMeterUtils.getResString("smtp_username"));
    // $NON-NLS-1$
    jlPassword = new JLabel(JMeterUtils.getResString("smtp_password"));
    // $NON-NLS-1$
    jlSubject = new JLabel(JMeterUtils.getResString("smtp_subject"));
    // $NON-NLS-1$
    jlMessage = new JLabel(JMeterUtils.getResString("smtp_message"));
    tfMailServer = new JTextField(30);
    tfMailServerPort = new JTextField(6);
    tfMailServerTimeout = new JTextField(6);
    tfMailServerConnectionTimeout = new JTextField(6);
    tfMailFrom = new JTextField(25);
    tfMailReplyTo = new JTextField(25);
    tfMailTo = new JTextField(25);
    tfMailToCC = new JTextField(25);
    tfMailToBCC = new JTextField(25);
    tfAuthUsername = new JTextField(20);
    tfAuthPassword = new JPasswordField(20);
    tfSubject = new JTextField(20);
    tfAttachment = new JTextField(30);
    tfEmlMessage = new JTextField(30);
    taMessage = new JTextArea(5, 20);
    // $NON-NLS-1$
    cbPlainBody = new JCheckBox(JMeterUtils.getResString("smtp_plainbody"));
    // $NON-NLS-1$
    cbSuppressSubject = new JCheckBox(JMeterUtils.getResString("smtp_suppresssubj"));
    cbSuppressSubject.addChangeListener(this::emptySubjectActionPerformed);
    // $NON-NLS-1$
    cbUseAuth = new JCheckBox(JMeterUtils.getResString("smtp_useauth"));
    // $NON-NLS-1$
    cbIncludeTimestamp = new JCheckBox(JMeterUtils.getResString("smtp_timestamp"));
    // $NON-NLS-1$
    cbMessageSizeStats = new JCheckBox(JMeterUtils.getResString("smtp_messagesize"));
    // $NON-NLS-1$
    cbEnableDebug = new JCheckBox(JMeterUtils.getResString("smtp_enabledebug"));
    // $NON-NLS-1$
    cbUseEmlMessage = new JCheckBox(JMeterUtils.getResString("smtp_eml"));
    attachmentFileChooser = new JFileChooser();
    emlFileChooser = new JFileChooser();
    // $NON-NLS-1$
    browseButton = new JButton(JMeterUtils.getResString("browse"));
    // $NON-NLS-1$
    emlBrowseButton = new JButton(JMeterUtils.getResString("browse"));
    attachmentFileChooser.addActionListener(this::attachmentFolderFileChooserActionPerformed);
    emlFileChooser.addActionListener(this::emlFileChooserActionPerformed);
    setLayout(new GridBagLayout());
    GridBagConstraints gridBagConstraintsMain = new GridBagConstraints();
    gridBagConstraintsMain.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraintsMain.anchor = GridBagConstraints.WEST;
    gridBagConstraintsMain.weightx = 0.5;
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.weightx = 0.5;
    /*
         * Server Settings
         */
    JPanel panelServerSettings = new VerticalPanel();
    panelServerSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_server_settings")));
    JPanel panelMailServer = new JPanel(new BorderLayout(5, 0));
    panelMailServer.add(jlMailServer, BorderLayout.WEST);
    panelMailServer.add(tfMailServer, BorderLayout.CENTER);
    JPanel panelMailServerPort = new JPanel(new BorderLayout(5, 0));
    panelMailServerPort.add(jlMailServerPort, BorderLayout.WEST);
    panelMailServerPort.add(tfMailServerPort, BorderLayout.CENTER);
    panelMailServerPort.add(jlDutPortStandard, BorderLayout.EAST);
    panelServerSettings.add(panelMailServer, BorderLayout.CENTER);
    panelServerSettings.add(panelMailServerPort, BorderLayout.SOUTH);
    JPanel panelServerTimeoutsSettings = new VerticalPanel();
    panelServerTimeoutsSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_server_timeouts_settings")));
    JPanel panelMailServerConnectionTimeout = new JPanel(new BorderLayout(5, 0));
    panelMailServerConnectionTimeout.add(jlMailServerConnectionTimeout, BorderLayout.WEST);
    panelMailServerConnectionTimeout.add(tfMailServerConnectionTimeout, BorderLayout.CENTER);
    JPanel panelMailServerTimeout = new JPanel(new BorderLayout(5, 0));
    panelMailServerTimeout.add(jlMailServerTimeout, BorderLayout.WEST);
    panelMailServerTimeout.add(tfMailServerTimeout, BorderLayout.CENTER);
    panelServerTimeoutsSettings.add(panelMailServerConnectionTimeout, BorderLayout.CENTER);
    panelServerTimeoutsSettings.add(panelMailServerTimeout, BorderLayout.SOUTH);
    JPanel panelServerConfig = new HorizontalPanel();
    panelServerConfig.add(panelServerSettings, BorderLayout.CENTER);
    panelServerConfig.add(panelServerTimeoutsSettings, BorderLayout.EAST);
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 0;
    add(panelServerConfig, gridBagConstraintsMain);
    /*
         * E-Mail Settings
         */
    JPanel panelMailSettings = new JPanel(new GridBagLayout());
    panelMailSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_mail_settings")));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    panelMailSettings.add(jlAddressFrom, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    panelMailSettings.add(tfMailFrom, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    panelMailSettings.add(jlAddressTo, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    panelMailSettings.add(tfMailTo, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    panelMailSettings.add(jlAddressToCC, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    panelMailSettings.add(tfMailToCC, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    panelMailSettings.add(jlAddressToBCC, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    panelMailSettings.add(tfMailToBCC, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    panelMailSettings.add(jlAddressReplyTo, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    panelMailSettings.add(tfMailReplyTo, gridBagConstraints);
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 1;
    add(panelMailSettings, gridBagConstraintsMain);
    /*
         * Auth Settings
         */
    JPanel panelAuthSettings = new JPanel(new GridBagLayout());
    panelAuthSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_auth_settings")));
    cbUseAuth.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    cbUseAuth.setMargin(new java.awt.Insets(0, 0, 0, 0));
    cbUseAuth.addActionListener(this::cbUseAuthActionPerformed);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    panelAuthSettings.add(cbUseAuth, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 1;
    gridBagConstraints.weightx = 0;
    panelAuthSettings.add(jlUsername, gridBagConstraints);
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.weightx = 0.5;
    panelAuthSettings.add(tfAuthUsername, gridBagConstraints);
    tfAuthUsername.setEditable(false);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 1;
    gridBagConstraints.weightx = 0;
    panelAuthSettings.add(jlPassword, gridBagConstraints);
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.weightx = 0.5;
    panelAuthSettings.add(tfAuthPassword, gridBagConstraints);
    tfAuthPassword.setEditable(false);
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 2;
    add(panelAuthSettings, gridBagConstraintsMain);
    /*
         * Security Settings
         */
    securitySettingsPanel = new SecuritySettingsPanel();
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 3;
    add(securitySettingsPanel, gridBagConstraintsMain);
    /*
         * (non-Javadoc) Message Settings
         */
    JPanel panelMessageSettings = new JPanel(new GridBagLayout());
    panelMessageSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_message_settings")));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    panelMessageSettings.add(jlSubject, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    panelMessageSettings.add(tfSubject, gridBagConstraints);
    cbSuppressSubject.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    cbSuppressSubject.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(cbSuppressSubject, gridBagConstraints);
    cbIncludeTimestamp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    cbIncludeTimestamp.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(cbIncludeTimestamp, gridBagConstraints);
    /*
         * Add the header panel
         */
    // $NON-NLS-1$
    addHeaderFieldButton = new JButton(JMeterUtils.getResString("smtp_header_add"));
    addHeaderFieldButton.addActionListener(this::addHeaderActionPerformed);
    // $NON-NLS-1$
    headerFieldName = new JLabel(JMeterUtils.getResString("smtp_header_name"));
    // $NON-NLS-1$
    headerFieldValue = new JLabel(JMeterUtils.getResString("smtp_header_value"));
    headerFieldsPanel = new JPanel(new GridBagLayout());
    headerFieldName.setVisible(false);
    headerFieldValue.setVisible(false);
    headerGridY = 0;
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = headerGridY++;
    headerFieldsPanel.add(addHeaderFieldButton, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = headerGridY;
    headerFieldsPanel.add(headerFieldName, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = headerGridY++;
    headerFieldsPanel.add(headerFieldValue, gridBagConstraints);
    gridBagConstraintsMain.gridx = 1;
    gridBagConstraintsMain.gridy = 2;
    panelMessageSettings.add(headerFieldsPanel, gridBagConstraintsMain);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    panelMessageSettings.add(jlMessage, gridBagConstraints);
    taMessage.setBorder(BorderFactory.createBevelBorder(1));
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    panelMessageSettings.add(taMessage, gridBagConstraints);
    cbPlainBody.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    cbPlainBody.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(cbPlainBody, gridBagConstraints);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(jlAttachFile, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    panelMessageSettings.add(tfAttachment, gridBagConstraints);
    // $NON-NLS-1$
    tfAttachment.setToolTipText(JMeterUtils.getResString("smtp_attach_file_tooltip"));
    browseButton.addActionListener(this::browseButtonActionPerformed);
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(browseButton, gridBagConstraints);
    cbUseEmlMessage.setSelected(false);
    cbUseEmlMessage.addActionListener(this::cbUseEmlMessageActionPerformed);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(cbUseEmlMessage, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    tfEmlMessage.setEnabled(false);
    panelMessageSettings.add(tfEmlMessage, gridBagConstraints);
    emlBrowseButton.addActionListener(this::emlBrowseButtonActionPerformed);
    emlBrowseButton.setEnabled(false);
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    panelMessageSettings.add(emlBrowseButton, gridBagConstraints);
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 6;
    add(panelMessageSettings, gridBagConstraintsMain);
    /*
         * Additional Settings
         */
    JPanel panelAdditionalSettings = new JPanel(new GridBagLayout());
    panelAdditionalSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("smtp_additional_settings")));
    cbMessageSizeStats.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    cbMessageSizeStats.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    panelAdditionalSettings.add(cbMessageSizeStats, gridBagConstraints);
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    panelAdditionalSettings.add(cbEnableDebug, gridBagConstraints);
    gridBagConstraintsMain.gridx = 0;
    gridBagConstraintsMain.gridy = 7;
    add(panelAdditionalSettings, gridBagConstraintsMain);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) JFileChooser(javax.swing.JFileChooser) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel)

Example 9 with JPasswordField

use of javax.swing.JPasswordField in project jmeter by apache.

the class HttpTestSampleGui method getProxyPassPanel.

private JPanel getProxyPassPanel() {
    proxyPass = new JPasswordField(5);
    // $NON-NLS-1$
    JLabel label = new JLabel(JMeterUtils.getResString("password"));
    label.setLabelFor(proxyPass);
    label.setFont(FONT_SMALL);
    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(proxyPass, BorderLayout.CENTER);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel)

Example 10 with JPasswordField

use of javax.swing.JPasswordField in project jdk8u_jdk by JetBrains.

the class PasswordView method getPreferredSpan.

/**
     * Determines the preferred span for this view along an
     * axis.
     *
     * @param axis may be either View.X_AXIS or View.Y_AXIS
     * @return   the span the view would like to be rendered into &gt;= 0.
     *           Typically the view is told to render into the span
     *           that is returned, although there is no guarantee.
     *           The parent may choose to resize or break the view.
     */
public float getPreferredSpan(int axis) {
    switch(axis) {
        case View.X_AXIS:
            Container c = getContainer();
            if (c instanceof JPasswordField) {
                JPasswordField f = (JPasswordField) c;
                if (f.echoCharIsSet()) {
                    char echoChar = f.getEchoChar();
                    FontMetrics m = f.getFontMetrics(f.getFont());
                    Document doc = getDocument();
                    return m.charWidth(echoChar) * getDocument().getLength();
                }
            }
    }
    return super.getPreferredSpan(axis);
}
Also used : JPasswordField(javax.swing.JPasswordField)

Aggregations

JPasswordField (javax.swing.JPasswordField)33 JTextField (javax.swing.JTextField)19 JLabel (javax.swing.JLabel)17 JPanel (javax.swing.JPanel)13 JCheckBox (javax.swing.JCheckBox)10 BorderLayout (java.awt.BorderLayout)9 JButton (javax.swing.JButton)8 JRadioButton (javax.swing.JRadioButton)5 JTextArea (javax.swing.JTextArea)5 Dimension (java.awt.Dimension)4 JComponent (javax.swing.JComponent)4 JTextPane (javax.swing.JTextPane)4 Component (java.awt.Component)3 GridBagLayout (java.awt.GridBagLayout)3 ArrayList (java.util.ArrayList)3 Font (java.awt.Font)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridLayout (java.awt.GridLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2