Search in sources :

Example 26 with JPasswordField

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

the class PasswordView method modelToView.

/**
     * Provides a mapping from the document model coordinate space
     * to the coordinate space of the view mapped to it.
     *
     * @param pos the position to convert >= 0
     * @param a the allocated region to render into
     * @return the bounding box of the given position
     * @exception BadLocationException  if the given position does not
     *   represent a valid location in the associated document
     * @see View#modelToView
     */
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (!f.echoCharIsSet()) {
            return super.modelToView(pos, a, b);
        }
        char echoChar = f.getEchoChar();
        FontMetrics m = f.getFontMetrics(f.getFont());
        Rectangle alloc = adjustAllocation(a).getBounds();
        int dx = (pos - getStartOffset()) * m.charWidth(echoChar);
        alloc.x += dx;
        alloc.width = 1;
        return alloc;
    }
    return null;
}
Also used : JPasswordField(javax.swing.JPasswordField)

Example 27 with JPasswordField

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

the class PasswordView method drawUnselectedText.

/**
     * Renders the given range in the model as normal unselected
     * text.  This sets the foreground color and echos the characters
     * using the value returned by getEchoChar().
     *
     * @param g the graphics context
     * @param x the starting X coordinate >= 0
     * @param y the starting Y coordinate >= 0
     * @param p0 the starting offset in the model >= 0
     * @param p1 the ending offset in the model >= p0
     * @return the X location of the end of the range >= 0
     * @exception BadLocationException if p0 or p1 are out of range
     */
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException {
    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (!f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        } else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
Also used : JPasswordField(javax.swing.JPasswordField)

Example 28 with JPasswordField

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

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 29 with JPasswordField

use of javax.swing.JPasswordField in project voltdb by VoltDB.

the class ConnectionDialogSwing method create.

private void create() {
    Box main = Box.createHorizontalBox();
    Box labels = Box.createVerticalBox();
    Box controls = Box.createVerticalBox();
    Box buttons = Box.createHorizontalBox();
    Box whole = Box.createVerticalBox();
    // (weconsultants@users) New code
    Box extra = Box.createHorizontalBox();
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createHorizontalGlue());
    main.add(labels);
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createHorizontalGlue());
    main.add(controls);
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createVerticalGlue());
    main.add(extra);
    main.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(main);
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(buttons);
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(Box.createVerticalGlue());
    labels.add(createLabel("Recent Setting:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Setting Name:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Type:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Driver:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("URL:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("User:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Password:"));
    labels.add(Box.createVerticalGlue());
    labels.add(Box.createVerticalStrut(10));
    controls.add(Box.createVerticalGlue());
    // (weconsultants@users) New code
    mSettingName.setActionCommand("Select Setting");
    mSettingName.addActionListener(this);
    controls.add(mSettingName);
    controls.add(Box.createHorizontalGlue());
    // (weconsultants@users) New code
    mName = new JTextField();
    mName.addActionListener(this);
    controls.add(mName);
    // (weconsultants@users) New code
    clear = new JButton("Clear Names");
    clear.setActionCommand("Clear");
    clear.addActionListener(this);
    buttons.add(clear);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    JComboBox types = new JComboBox();
    connTypes = ConnectionDialogCommon.getTypes();
    for (int i = 0; i < connTypes.length; i++) {
        types.addItem(connTypes[i][0]);
    }
    types.addItemListener(this);
    controls.add(types);
    controls.add(Box.createVerticalGlue());
    mDriver = new JTextField(connTypes[0][1]);
    mDriver.addActionListener(this);
    controls.add(mDriver);
    mURL = new JTextField(connTypes[0][2]);
    mURL.addActionListener(this);
    controls.add(mURL);
    controls.add(Box.createVerticalGlue());
    mUser = new JTextField("SA");
    mUser.addActionListener(this);
    controls.add(mUser);
    controls.add(Box.createVerticalGlue());
    mPassword = new JPasswordField("");
    mPassword.addActionListener(this);
    controls.add(mPassword);
    controls.add(Box.createVerticalGlue());
    controls.add(Box.createVerticalStrut(10));
    // The button bar
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    okCancel = new JButton("     Ok      ");
    okCancel.setActionCommand("ConnectOk");
    okCancel.addActionListener(this);
    buttons.add(okCancel);
    getRootPane().setDefaultButton(okCancel);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(20));
    okCancel = new JButton("  Cancel   ");
    okCancel.setActionCommand("ConnectCancel");
    okCancel.addActionListener(this);
    buttons.add(okCancel);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    JPanel jPanel = new JPanel();
    jPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    jPanel.add("Center", whole);
    getContentPane().add("Center", jPanel);
    doLayout();
    pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = getSize();
    if (currentConnectionSetting != null) {
        mName.setText(currentConnectionSetting.getName());
        mDriver.setText(currentConnectionSetting.getDriver());
        mURL.setText(currentConnectionSetting.getUrl());
        mUser.setText(currentConnectionSetting.getUser());
        mPassword.setText(currentConnectionSetting.getPassword());
    }
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) JPasswordField(javax.swing.JPasswordField) JButton(javax.swing.JButton) Box(javax.swing.Box) JComboBox(javax.swing.JComboBox) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) EmptyBorder(javax.swing.border.EmptyBorder)

Example 30 with JPasswordField

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

the class HttpDefaultsGui 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)

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