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;
}
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;
}
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");
}
}
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);
}
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;
}
Aggregations