use of javax.swing.JTextField in project jgnash by ccavanaugh.
the class NetworkAuthenticator method getPasswordAuthentication.
@Override
protected PasswordAuthentication getPasswordAuthentication() {
Preferences auth = Preferences.userRoot().node(NODEHTTP);
char[] pass = null;
String user;
// get the password
String _pass = auth.get(HTTPPASS, null);
if (_pass != null) {
if (!_pass.isEmpty()) {
pass = _pass.toCharArray();
}
}
// get the user
user = auth.get(HTTPUSER, null);
if (user != null) {
if (user.length() <= 0) {
user = null;
}
}
// if either returns null, pop a dialog
if (user == null || pass == null) {
JTextField username = new JTextField();
JPasswordField password = new JPasswordField();
JPanel panel = new JPanel(new GridLayout(2, 2));
panel.add(new JLabel(ResourceUtils.getString("Label.UserName")));
panel.add(username);
panel.add(new JLabel(ResourceUtils.getString("Label.Password")));
panel.add(password);
int option = JOptionPane.showConfirmDialog(null, new Object[] { "Site: " + getRequestingHost(), "Realm: " + getRequestingPrompt(), panel }, "Enter Network Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (option == JOptionPane.OK_OPTION) {
user = username.getText();
pass = password.getPassword();
} else {
return null;
}
}
return new PasswordAuthentication(user, pass);
}
use of javax.swing.JTextField in project jgnash by ccavanaugh.
the class AccountOptions method initComponents.
private void initComponents() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
accountSeparatorField = new JTextField(engine.getAccountSeparator());
useAccountTermsCheckBox = new JCheckBox(rb.getString("Button.AccTerms"));
noneButton = new JRadioButton(rb.getString("Button.None"));
noneButton.setToolTipText(rb.getString("ToolTip.ReversedSignNone"));
creditAccountsButton = new JRadioButton(rb.getString("Button.CreditAccounts"));
creditAccountsButton.setToolTipText(rb.getString("ToolTip.ReversedCredit"));
incomeExpenseAccountsButton = new JRadioButton(rb.getString("Button.IncomeAndExpense"));
incomeExpenseAccountsButton.setToolTipText(rb.getString("ToolTip.ReversedIncomeExpense"));
ButtonGroup group = new ButtonGroup();
group.add(noneButton);
group.add(creditAccountsButton);
group.add(incomeExpenseAccountsButton);
}
use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.
the class MetalworksDocumentFrame method buildAddressPanel.
private JPanel buildAddressPanel() {
JPanel p = new JPanel();
p.setLayout(new LabeledPairLayout());
JLabel toLabel = new JLabel("To: ", JLabel.RIGHT);
JTextField toField = new JTextField(25);
p.add(toLabel, "label");
p.add(toField, "field");
JLabel subLabel = new JLabel("Subj: ", JLabel.RIGHT);
JTextField subField = new JTextField(25);
p.add(subLabel, "label");
p.add(subField, "field");
JLabel ccLabel = new JLabel("cc: ", JLabel.RIGHT);
JTextField ccField = new JTextField(25);
p.add(ccLabel, "label");
p.add(ccField, "field");
return p;
}
use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.
the class TableExample method createConnectionDialog.
/**
* Creates the connectionPanel, which will contain all the fields for
* the connection information.
*/
public void createConnectionDialog() {
// Create the labels and text fields.
userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
userNameField = new JTextField("app");
passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
passwordField = new JTextField("app");
serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
serverField = new JTextField("jdbc:derby://localhost:1527/sample");
driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
driverField = new JTextField("org.apache.derby.jdbc.ClientDriver");
connectionPanel = new JPanel(false);
connectionPanel.setLayout(new BoxLayout(connectionPanel, BoxLayout.X_AXIS));
JPanel namePanel = new JPanel(false);
namePanel.setLayout(new GridLayout(0, 1));
namePanel.add(userNameLabel);
namePanel.add(passwordLabel);
namePanel.add(serverLabel);
namePanel.add(driverLabel);
JPanel fieldPanel = new JPanel(false);
fieldPanel.setLayout(new GridLayout(0, 1));
fieldPanel.add(userNameField);
fieldPanel.add(passwordField);
fieldPanel.add(serverField);
fieldPanel.add(driverField);
connectionPanel.add(namePanel);
connectionPanel.add(fieldPanel);
}
use of javax.swing.JTextField in project jabref by JabRef.
the class BibtexKeyPatternPanel method buildGUI.
private void buildGUI() {
JPanel pan = new JPanel();
JScrollPane sp = new JScrollPane(pan);
sp.setPreferredSize(new Dimension(100, 100));
sp.setBorder(BorderFactory.createEmptyBorder());
pan.setLayout(gbl);
setLayout(gbl);
// The header - can be removed
JLabel lblEntryType = new JLabel(Localization.lang("Entry type"));
Font f = new Font("plain", Font.BOLD, 12);
lblEntryType.setFont(f);
con.gridx = 0;
con.gridy = 0;
con.gridwidth = 1;
con.gridheight = 1;
con.fill = GridBagConstraints.VERTICAL;
con.anchor = GridBagConstraints.WEST;
con.insets = new Insets(5, 5, 10, 0);
gbl.setConstraints(lblEntryType, con);
pan.add(lblEntryType);
JLabel lblKeyPattern = new JLabel(Localization.lang("Key pattern"));
lblKeyPattern.setFont(f);
con.gridx = 1;
con.gridy = 0;
con.gridheight = 1;
con.fill = GridBagConstraints.HORIZONTAL;
con.anchor = GridBagConstraints.WEST;
con.insets = new Insets(5, 5, 10, 5);
gbl.setConstraints(lblKeyPattern, con);
pan.add(lblKeyPattern);
con.gridy = 1;
con.gridx = 0;
JLabel lab = new JLabel(Localization.lang("Default pattern"));
gbl.setConstraints(lab, con);
pan.add(lab);
con.gridx = 1;
gbl.setConstraints(defaultPat, con);
pan.add(defaultPat);
con.insets = new Insets(5, 5, 10, 5);
JButton btnDefault = new JButton(Localization.lang("Default"));
btnDefault.addActionListener(e -> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
con.gridx = 2;
int y = 2;
gbl.setConstraints(btnDefault, con);
pan.add(btnDefault);
BibDatabaseMode mode;
// check mode of currently used DB
if (panel != null) {
mode = panel.getBibDatabaseContext().getMode();
} else {
// use preferences value if no DB is open
mode = Globals.prefs.getDefaultBibDatabaseMode();
}
for (EntryType type : EntryTypes.getAllValues(mode)) {
textFields.put(type.getName().toLowerCase(Locale.ROOT), addEntryType(pan, type, y));
y++;
}
con.fill = GridBagConstraints.BOTH;
con.gridx = 0;
con.gridy = 1;
con.gridwidth = 3;
con.weightx = 1;
con.weighty = 1;
gbl.setConstraints(sp, con);
add(sp);
// A help button
con.gridwidth = 1;
con.gridx = 1;
con.gridy = 2;
con.fill = GridBagConstraints.HORIZONTAL;
//
con.weightx = 0;
con.weighty = 0;
con.anchor = GridBagConstraints.SOUTHEAST;
con.insets = new Insets(0, 5, 0, 5);
JButton hlb = new JButton(IconTheme.JabRefIcon.HELP.getSmallIcon());
hlb.setToolTipText(Localization.lang("Help on key patterns"));
gbl.setConstraints(hlb, con);
add(hlb);
hlb.addActionListener(help);
// And finally a button to reset everything
JButton btnDefaultAll = new JButton(Localization.lang("Reset all"));
con.gridx = 2;
con.gridy = 2;
con.weightx = 1;
con.weighty = 0;
con.anchor = GridBagConstraints.SOUTHEAST;
con.insets = new Insets(20, 5, 0, 5);
gbl.setConstraints(btnDefaultAll, con);
btnDefaultAll.addActionListener(e -> {
for (JTextField field : textFields.values()) {
field.setText("");
}
defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
});
add(btnDefaultAll);
}
Aggregations