Search in sources :

Example 76 with KeyAdapter

use of java.awt.event.KeyAdapter in project JMRI by JMRI.

the class ProfileManagerDialog method initComponents.

/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    listLabel = new JLabel();
    jScrollPane1 = new JScrollPane();
    profiles = new JList<>();
    btnSelect = new JButton();
    btnCreate = new JButton();
    btnUseExisting = new JButton();
    countDownLbl = new JLabel();
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    // NOI18N
    setTitle(Bundle.getMessage("ProfileManagerDialog.title"));
    setMinimumSize(new Dimension(310, 110));
    addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            formMousePressed(evt);
        }
    });
    addWindowListener(new WindowAdapter() {

        public void windowOpened(WindowEvent evt) {
            formWindowOpened(evt);
        }

        public void windowClosing(WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
    // NOI18N
    listLabel.setText(Bundle.getMessage("ProfileManagerDialog.listLabel.text"));
    profiles.setModel(new ProfileListModel());
    profiles.setSelectedValue(ProfileManager.getDefault().getActiveProfile(), true);
    profiles.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // NOI18N
    profiles.setToolTipText(Bundle.getMessage("ProfileManagerDialog.profiles.toolTipText"));
    profiles.setCellRenderer(new ProfileListCellRenderer());
    profiles.setNextFocusableComponent(btnSelect);
    profiles.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent evt) {
            profilesKeyPressed(evt);
        }
    });
    profiles.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            profilesValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(profiles);
    profiles.ensureIndexIsVisible(profiles.getSelectedIndex());
    // NOI18N
    profiles.getAccessibleContext().setAccessibleName(Bundle.getMessage("ProfileManagerDialog.profiles.AccessibleContext.accessibleName"));
    // NOI18N
    btnSelect.setText(Bundle.getMessage("ProfileManagerDialog.btnSelect.text"));
    btnSelect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnSelectActionPerformed(evt);
        }
    });
    // NOI18N
    btnCreate.setText(Bundle.getMessage("ProfileManagerDialog.btnCreate.text"));
    // NOI18N
    btnCreate.setToolTipText(Bundle.getMessage("ProfilePreferencesPanel.btnCreateNewProfile.toolTipText"));
    btnCreate.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnCreateActionPerformed(evt);
        }
    });
    // NOI18N
    btnUseExisting.setText(Bundle.getMessage("ProfileManagerDialog.btnUseExisting.text"));
    btnUseExisting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnUseExistingActionPerformed(evt);
        }
    });
    // NOI18N
    countDownLbl.setText(Bundle.getMessage("ProfileManagerDialog.countDownLbl.text"));
    // NOI18N
    countDownLbl.setToolTipText(Bundle.getMessage("ProfileManagerDialog.countDownLbl.toolTipText"));
    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(listLabel).addComponent(countDownLbl)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(btnUseExisting).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnCreate).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnSelect)).addComponent(jScrollPane1)).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE).addComponent(listLabel)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(btnSelect).addComponent(btnCreate).addComponent(btnUseExisting).addComponent(countDownLbl)).addContainerGap()));
    // NOI18N
    listLabel.getAccessibleContext().setAccessibleName(Bundle.getMessage("ProfileManagerDialog.listLabel.text"));
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) KeyEvent(java.awt.event.KeyEvent) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) GroupLayout(javax.swing.GroupLayout)

Example 77 with KeyAdapter

use of java.awt.event.KeyAdapter in project cayenne by apache.

the class PathChooserComboBoxCellEditor method initializeCombo.

protected void initializeCombo(CayenneTableModel model, int row, final JTable table) {
    Object currentNode = getCurrentNodeToInitializeCombo(model, row);
    String dbAttributePath = getPathToInitializeCombo(model, row);
    List<String> nodeChildren = getChildren(currentNode, dbAttributePath);
    this.table = table;
    comboBoxPathChooser = Application.getWidgetFactory().createComboBox(nodeChildren, false);
    comboBoxPathChooser.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.VK_ENTER) {
                enterPressed(table);
                return;
            }
            parsePathString(event.getKeyChar());
        }
    });
    AutoCompletion.enable(comboBoxPathChooser, true, true);
    ((JComponent) comboBoxPathChooser.getEditor().getEditorComponent()).setBorder(null);
    comboBoxPathChooser.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    comboBoxPathChooser.setRenderer(new PathChooserComboBoxCellRenderer());
    comboBoxPathChooser.addActionListener(this);
    comboBoxPathChooser.addPopupMenuListener(this);
}
Also used : KeyEvent(java.awt.event.KeyEvent) KeyAdapter(java.awt.event.KeyAdapter) JComponent(javax.swing.JComponent)

Aggregations

KeyAdapter (java.awt.event.KeyAdapter)77 KeyEvent (java.awt.event.KeyEvent)75 MouseEvent (java.awt.event.MouseEvent)29 MouseAdapter (java.awt.event.MouseAdapter)19 JPanel (javax.swing.JPanel)16 ActionEvent (java.awt.event.ActionEvent)15 JLabel (javax.swing.JLabel)15 ActionListener (java.awt.event.ActionListener)14 JScrollPane (javax.swing.JScrollPane)13 BorderLayout (java.awt.BorderLayout)12 JButton (javax.swing.JButton)12 JTextField (javax.swing.JTextField)11 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)11 TreePath (javax.swing.tree.TreePath)11 NotNull (org.jetbrains.annotations.NotNull)11 FlowLayout (java.awt.FlowLayout)10 Tree (com.intellij.ui.treeStructure.Tree)9 Dimension (java.awt.Dimension)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ListSelectionListener (javax.swing.event.ListSelectionListener)9