use of javax.swing.JPasswordField in project compss by bsc-wdc.
the class SubmitRemoteJob method getPassphrase.
private static String getPassphrase() {
JPasswordField pwd = new JPasswordField();
Object[] message = { "grid-proxy-init\nPlease enter your passphrase.", pwd };
JOptionPane.showMessageDialog(null, message, "Grid-Proxy-Init", JOptionPane.QUESTION_MESSAGE);
return new String(pwd.getPassword());
}
use of javax.swing.JPasswordField in project openmrs-core by openmrs.
the class BaseContextSensitiveTest method askForUsernameAndPassword.
/**
* Utility method for obtaining username and password through Swing interface for tests. Any
* tests extending the org.openmrs.BaseTest class may simply invoke this method by name.
* Username and password are returned in a two-member String array. If the user aborts, null is
* returned. <b> <em>Do not call for non-interactive tests, since this method will try to
* render an interactive dialog box for authentication!</em></b>
*
* @param message string to display above username field
* @return Two-member String array containing username and password, respectively, or
* <code>null</code> if user aborts dialog
*/
public static synchronized String[] askForUsernameAndPassword(String message) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
if (message == null || "".equals(message))
message = "Enter username/password to authenticate to OpenMRS...";
JPanel panel = new JPanel(new GridBagLayout());
JLabel usernameLabel = new JLabel("Username");
usernameLabel.setFont(font);
usernameField = new JTextField(20);
usernameField.setFont(font);
JLabel passwordLabel = new JLabel("Password");
passwordLabel.setFont(font);
JPasswordField passwordField = new JPasswordField(20);
passwordField.setFont(font);
panel.add(usernameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
panel.add(usernameField, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
panel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
panel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
frame = new JFrame();
Window window = new Window(frame);
frame.setVisible(true);
frame.setTitle("JUnit Test Credentials");
// We use a TimerTask to force focus on username, but still use
// JOptionPane for model dialog
TimerTask later = new TimerTask() {
@Override
public void run() {
if (frame != null) {
// bring the dialog's window to the front
frame.toFront();
usernameField.grabFocus();
}
}
};
// try setting focus half a second from now
new Timer().schedule(later, 500);
// attention grabber for those people that aren't as observant
TimerTask laterStill = new TimerTask() {
@Override
public void run() {
if (frame != null) {
// bring the dialog's window to the
frame.toFront();
// front
usernameField.grabFocus();
}
}
};
// if the user hasn't done anything in 10 seconds, tell them the window
// is there
new Timer().schedule(laterStill, 10000);
// show the dialog box
int response = JOptionPane.showConfirmDialog(window, panel, message, JOptionPane.OK_CANCEL_OPTION);
// clear out the window so the timer doesn't screw up
laterStill.cancel();
frame.setVisible(false);
window.setVisible(false);
frame = null;
// X in the top right
return (response == 2 || response == -1 ? null : new String[] { usernameField.getText(), String.valueOf(passwordField.getPassword()) });
}
use of javax.swing.JPasswordField in project ili2db by claeis.
the class GpkgDbPanel method getDbpwdUi.
/**
* This method initializes dbpwdUi
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getDbpwdUi() {
if (dbpwdUi == null) {
dbpwdUi = new JPasswordField();
dbpwdUi.setColumns(40);
}
return dbpwdUi;
}
use of javax.swing.JPasswordField in project ili2db by claeis.
the class PgDbPanel method getDbpwdUi.
/**
* This method initializes dbpwdUi
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getDbpwdUi() {
if (dbpwdUi == null) {
dbpwdUi = new JPasswordField();
dbpwdUi.setColumns(40);
}
return dbpwdUi;
}
use of javax.swing.JPasswordField in project ili2db by claeis.
the class GeodbDbPanel method getDbpwdUi.
/**
* This method initializes dbpwdUi
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getDbpwdUi() {
if (dbpwdUi == null) {
dbpwdUi = new JPasswordField();
dbpwdUi.setColumns(40);
}
return dbpwdUi;
}
Aggregations