use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class SSHCredentialsDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gb = new GridBagConstraints();
// top label.
gb.insets = JBUI.insets(2);
gb.weightx = 1;
gb.weighty = 0;
gb.gridwidth = 3;
gb.gridheight = 1;
gb.gridx = 0;
gb.gridy = 0;
gb.anchor = GridBagConstraints.WEST;
gb.fill = GridBagConstraints.HORIZONTAL;
JLabel label = new JLabel(SvnBundle.message("label.ssh.authentication.realm", myRealm));
panel.add(label, gb);
// user name
gb.gridy += 1;
gb.gridwidth = 1;
gb.weightx = 0;
gb.fill = GridBagConstraints.NONE;
label = new JLabel(SvnBundle.message("label.ssh.user.name"));
panel.add(label, gb);
// user name field
gb.gridx = 1;
gb.gridwidth = 2;
gb.weightx = 1;
gb.fill = GridBagConstraints.HORIZONTAL;
myUserNameText = new JTextField();
panel.add(myUserNameText, gb);
label.setLabelFor(myUserNameText);
if (myUserName != null) {
myUserNameText.setText(myUserName);
}
myUserNameText.selectAll();
myUserNameText.getDocument().addDocumentListener(this);
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 3;
// ssh agent type
mySshAgentButton = new JBRadioButton(SvnBundle.message("radio.ssh.authentication.with.agent"));
panel.add(mySshAgentButton, gb);
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 3;
// password type
myPasswordButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.with.password"));
panel.add(myPasswordButton, gb);
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.gridwidth = 1;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 1;
myPasswordLabel = new JLabel(SvnBundle.message("label.ssh.password"));
panel.add(myPasswordLabel, gb);
// passworde field
gb.gridx = 1;
gb.weightx = 1;
gb.gridwidth = 2;
gb.fill = GridBagConstraints.HORIZONTAL;
myPasswordText = new JPasswordField();
panel.add(myPasswordText, gb);
myPasswordLabel.setLabelFor(myPasswordText);
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 3;
myKeyButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.private.key"));
panel.add(myKeyButton, gb);
// key file.
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.gridwidth = 1;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 1;
myKeyFileLabel = new JLabel(SvnBundle.message("label.ssh.key.file"));
panel.add(myKeyFileLabel, gb);
// key field
gb.gridx = 1;
gb.weightx = 1;
gb.gridwidth = 2;
gb.fill = GridBagConstraints.HORIZONTAL;
myKeyFileText = new TextFieldWithBrowseButton(this);
myKeyFileText.setEditable(false);
panel.add(myKeyFileText, gb);
myKeyFileLabel.setLabelFor(myKeyFileText);
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.gridwidth = 1;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 1;
myPassphraseLabel = new JLabel(SvnBundle.message("label.ssh.passphrase"));
panel.add(myPassphraseLabel, gb);
// key field
gb.gridx = 1;
gb.weightx = 1;
gb.gridwidth = 2;
gb.fill = GridBagConstraints.HORIZONTAL;
myPassphraseText = new JPasswordField(30);
panel.add(myPassphraseText, gb);
myPassphraseText.getDocument().addDocumentListener(this);
myPassphraseText.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
checkKeyFile();
updateOKButton();
}
});
myPassphraseLabel.setLabelFor(myPassphraseText);
// key file.
gb.gridy += 1;
gb.weightx = 0;
gb.gridx = 0;
gb.gridwidth = 1;
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 1;
myPortLabel = new JLabel(SvnBundle.message("label.ssh.port"));
panel.add(myPortLabel, gb);
// key field
gb.gridx = 1;
gb.weightx = 0;
gb.gridwidth = 2;
gb.fill = GridBagConstraints.NONE;
myPortField = new JTextField();
myPortField.setColumns(6);
panel.add(myPortField, gb);
myPortLabel.setLabelFor(myPortField);
myPortField.setText("22");
myPortField.setMinimumSize(myPortField.getPreferredSize());
myPortField.getDocument().addDocumentListener(this);
ButtonGroup group = new ButtonGroup();
group.add(mySshAgentButton);
group.add(myPasswordButton);
group.add(myKeyButton);
mySshAgentButton.setEnabled(myIsAgentAllowed);
group.setSelected((myIsAgentAllowed ? mySshAgentButton : myPasswordButton).getModel(), true);
gb.gridy += 1;
gb.gridx = 0;
gb.gridwidth = 3;
gb.weightx = 1;
gb.anchor = GridBagConstraints.WEST;
gb.fill = GridBagConstraints.HORIZONTAL;
myAllowSaveCheckBox = new JCheckBox(SvnBundle.message("checkbox.ssh.keep.for.current.session"));
panel.add(myAllowSaveCheckBox, gb);
if (!myAllowSave) {
gb.gridy += 1;
final JLabel cannotSaveLabel = new JLabel(SvnBundle.message("svn.cannot.save.credentials.store-auth-creds"));
cannotSaveLabel.setForeground(UIUtil.getInactiveTextColor());
panel.add(cannotSaveLabel, gb);
}
gb.gridy += 1;
panel.add(new JSeparator(), gb);
gb.gridy += 1;
gb.weighty = 1;
panel.add(new JLabel(), gb);
myAllowSaveCheckBox.setSelected(false);
myAllowSaveCheckBox.setEnabled(myAllowSave);
mySshAgentButton.addActionListener(this);
myKeyButton.addActionListener(this);
myPasswordButton.addActionListener(this);
updateFields();
updateOKButton();
return panel;
}
use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class BaseControl method initialize.
private void initialize(final Bound boundComponent) {
myBoundComponent = createMainComponent(boundComponent);
final JComponent highlightedComponent = getHighlightedComponent(myBoundComponent);
myDefaultForeground = highlightedComponent.getForeground();
myDefaultBackground = highlightedComponent.getBackground();
final JComponent component = getComponentToListenFocusLost(myBoundComponent);
if (component != null) {
component.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
if (!e.isTemporary() && isValid()) {
commit();
}
}
});
}
updateComponent();
}
use of java.awt.event.FocusEvent in project Botnak by Gocnak.
the class BaseTextAreaUI method installListeners.
protected void installListeners() {
super.installListeners();
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
focusListener = new FocusListener() {
public void focusGained(FocusEvent e) {
if (getComponent() != null) {
orgBorder = getComponent().getBorder();
LookAndFeel laf = UIManager.getLookAndFeel();
if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
getComponent().setBorder(focusBorder);
}
getComponent().invalidate();
getComponent().repaint();
}
}
public void focusLost(FocusEvent e) {
if (getComponent() != null) {
if (orgBorder instanceof UIResource) {
getComponent().setBorder(orgBorder);
}
getComponent().invalidate();
getComponent().repaint();
}
}
};
getComponent().addFocusListener(focusListener);
}
}
use of java.awt.event.FocusEvent in project Botnak by Gocnak.
the class BaseFormattedTextFieldUI method installListeners.
protected void installListeners() {
super.installListeners();
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
focusListener = new FocusListener() {
public void focusGained(FocusEvent e) {
if (getComponent() != null) {
orgBorder = getComponent().getBorder();
LookAndFeel laf = UIManager.getLookAndFeel();
if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
getComponent().setBorder(focusBorder);
}
getComponent().invalidate();
getComponent().repaint();
}
}
public void focusLost(FocusEvent e) {
if (getComponent() != null) {
if (orgBorder instanceof UIResource) {
getComponent().setBorder(orgBorder);
getComponent().invalidate();
getComponent().repaint();
}
}
}
};
getComponent().addFocusListener(focusListener);
}
}
use of java.awt.event.FocusEvent in project EnrichmentMapApp by BaderLab.
the class SliderBarPanel method getTextField.
public JFormattedTextField getTextField() {
if (textField == null) {
textField = new JFormattedTextField(format) {
@Override
public Dimension getPreferredSize() {
final Dimension d = super.getPreferredSize();
if (this.getGraphics() != null) {
// Set the preferred text field size after it gets a Graphics
int sw = 16 + this.getGraphics().getFontMetrics().stringWidth(format.format(max));
d.width = Math.max(sw, 48);
}
return d;
}
};
textField.setHorizontalAlignment(JTextField.RIGHT);
textField.addActionListener(evt -> {
textFieldValueChanged();
});
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
textFieldValueChanged();
}
});
}
return textField;
}
Aggregations