use of java.awt.event.InputMethodListener in project intellij-community by JetBrains.
the class AddRepositoryLocationDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JLabel selectText = new JLabel(message("repository.browser.add.location.prompt"));
selectText.setUI(new MultiLineLabelUI());
JPanel mainPanel = new JPanel(new GridBagLayout());
GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, NORTHWEST, NONE, insets(5), 0, 0);
mainPanel.add(selectText, gb);
++gb.gridy;
myCombo = new ComboBox<>(new CollectionComboBoxModel<>(myPreviousLocations));
myCombo.setEditable(true);
myCombo.setMinimumSize(size(250, 20));
gb.fill = HORIZONTAL;
mainPanel.add(myCombo, gb);
gb.fill = NONE;
myComboField = (JTextField) myCombo.getEditor().getEditorComponent();
myComboField.addInputMethodListener(new InputMethodListener() {
public void inputMethodTextChanged(InputMethodEvent event) {
validateMe();
}
public void caretPositionChanged(InputMethodEvent event) {
validateMe();
}
});
myComboField.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
validateMe();
}
public void keyPressed(KeyEvent e) {
validateMe();
}
public void keyReleased(KeyEvent e) {
validateMe();
}
});
myCombo.addActionListener(e -> validateMe());
validateMe();
JPanel wrapper = new JPanel(new GridBagLayout());
wrapper.add(mainPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, NORTHWEST, HORIZONTAL, emptyInsets(), 0, 0));
wrapper.setPreferredSize(size(400, 70));
return wrapper;
}
Aggregations