jList1.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) {
DoubleClickListener doubleClickListener = new DoubleClickListener(); nodeList.addMouseListener(doubleClickListener); nodeList.addKeyListener(escapeListener); nodeList.addKeyListener(arrowKeysListener); nodeList.setSelectedIndex(0); nodeList.setCellRenderer(new NodeRenderer());
JList makeJList(Vector items) { JList list = new JList(items); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(this); list.addKeyListener(this); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { runSelectedCommand(); dialog.dispose(); } } }); return list; }
public static <T> void install(JList<T> list, JListContextMenuListener<T> listener) { JListActionHelper<T> helper = new JListActionHelper<>(list, listener); list.addMouseListener(helper); list.addKeyListener(helper); }
private void setupList() { list.getSelectionModel().addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireAction(); } } }); list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { fireAction(); } }); list.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getExtendedKeyCode() == KeyEvent.VK_SPACE) { fireAction(); } if (e.getExtendedKeyCode() == KeyEvent.VK_ENTER) { fireAction(); } } }); }
private JPopupMenu addPopupMenu(JList list, String... actions) { JPopupMenu favoritesPopupMenu = new JPopupMenu(); for (String action : actions) { favoritesPopupMenu.add(list.getActionMap().get(action)); } list.addKeyListener(new PopupListener(favoritesPopupMenu)); list.addMouseListener(new PopupListener(favoritesPopupMenu)); return favoritesPopupMenu; }
public StyleClassPropertyPanel(StyleClassPropertyEditor editor) { super(editor); assert(editor != null); this.editor = editor; // Initialize list models this.selectedListModel = new DefaultListModel(); String[] selectedStyleClasses = editor.getStyleClasses(); Set selectStyleClassesSet = new HashSet(); for (int i = 0; i < selectedStyleClasses.length; i++) { this.selectedListModel.addElement(selectedStyleClasses[i]); selectStyleClassesSet.add(selectedStyleClasses[i]); } this.availableListModel = new DefaultListModel(); String[] availableStyleClasses = editor.getAvailableStyleClasses(); for (int i = 0; i < availableStyleClasses.length; i++) { if (!selectStyleClassesSet.contains(availableStyleClasses[i])) this.availableListModel.addElement(availableStyleClasses[i]); } // Initialize UI components initComponents(); this.availableList.addKeyListener(new ListKeyListener(this.availableList)); }
/** * Creates new form MyList */ public MyList() { initComponents(); DefaultListModel dlm = new DefaultListModel(); jList.setModel(dlm); dlm.addListDataListener(this); jList.addKeyListener( new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { int keyChar = e.getKeyChar(); switch (keyChar) { case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: List selected = jList.getSelectedValuesList(); for (Object o : selected) { ((DefaultListModel) jList.getModel()).removeElement(o); } } } }); }
private TableGeneratorPanel() { initComponents(); columnList.setCellRenderer(new CheckRenderer()); CheckListener checkListener = new CheckListener(); columnList.addKeyListener(checkListener); columnList.addMouseListener(checkListener); connVariableTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { updateErrorState(); } @Override public void removeUpdate(DocumentEvent e) { updateErrorState(); } @Override public void changedUpdate(DocumentEvent e) { updateErrorState(); } }); }
private void initList(){ initListModel(); stylesList.addListSelectionListener(this); stylesList.addKeyListener(this); stylesList.addMouseListener(this); stylesList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set focus. stylesList.setSelectedIndex(0); stylesList.requestFocus(); checkSelection(); }
protected void createSelectedList() { $objectMap.put("selectedList", selectedList = new JList()); selectedList.setName("selectedList"); selectedList.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__selectedList")); selectedList.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__selectedList")); selectedList.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__selectedList")); }
protected void createUniverseList() { $objectMap.put("universeList", universeList = new JList()); universeList.setName("universeList"); universeList.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__universeList")); universeList.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__universeList")); universeList.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__universeList")); }
public JComponent overlayCreateInterface() { JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("Go To Rule:"), BorderLayout.NORTH); ruleNameField = new JTextField(); ruleNameField.addKeyListener(new TextFieldKeyAdapter()); ruleNameField.getDocument().addDocumentListener(new TextFieldDocumentListener()); matchingRuleListModel = new DefaultListModel(); matchingRuleList = new JList(matchingRuleListModel); matchingRuleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); matchingRuleList.setBackground(new Color(235, 244, 254)); matchingRuleList.setPrototypeCellValue("This is a rule name g"); matchingRuleList.addKeyListener(new ListKeyAdapter()); // FIX AW-85 matchingRuleList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if(mouseEvent.getClickCount() == 2) { goToRule(); hide(); } } }); matchingRuleScrollPane = new JScrollPane(matchingRuleList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); matchingRuleScrollPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); matchingRuleScrollPane.setVisible(false); parentFrame.getLayeredPane().add(matchingRuleScrollPane, JLayeredPane.MODAL_LAYER); panel.add(ruleNameField, BorderLayout.SOUTH); return panel; }
/** * Create a completion popup. * It is not shown until reset() method is called with valid * candidates. All key events for the view are intercepted by * this popup untill end of completion. * @since jEdit 4.3pre13 */ public CompletionPopup(View view) { super(view); this.view = view; this.keyHandler = new KeyHandler(); this.candidates = null; this.list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setCellRenderer(new CellRenderer()); list.addKeyListener(keyHandler); list.addMouseListener(new MouseHandler()); JPanel content = new JPanel(new BorderLayout()); content.setFocusTraversalKeysEnabled(false); // stupid scrollbar policy is an attempt to work around // bugs people have been seeing with IBM's JDK -- 7 Sep 2000 JScrollPane scroller = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); content.add(scroller, BorderLayout.CENTER); setContentPane(content); addWindowFocusListener(new WindowFocusHandler()); }
/** * Create a completion popup. * It is not shown until reset() method is called with valid * candidates. All key events for the view are intercepted by * this popup untill end of completion. * @since jEdit 4.3pre13 */ public CompletionPopup(ViewInterface view) { super(view.getFrame()); this.view = view; this.keyHandler = new KeyHandler(); this.candidates = null; this.list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setCellRenderer(new CellRenderer()); list.addKeyListener(keyHandler); list.addMouseListener(new MouseHandler()); JPanel content = new JPanel(new BorderLayout()); content.setFocusTraversalKeysEnabled(false); // stupid scrollbar policy is an attempt to work around // bugs people have been seeing with IBM's JDK -- 7 Sep 2000 JScrollPane scroller = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); content.add(scroller, BorderLayout.CENTER); setContentPane(content); addWindowFocusListener(new WindowFocusHandler()); }
/** Creates new form FindPanel */ public FindPanel(FindWizardPanel wizardPanel) { this.wizardPanel = wizardPanel; JavaPlatform p[] = JavaPlatformManager.getDefault().getInstalledPlatforms(); for (JavaPlatform jp : p) { if (jp instanceof J2MEPlatform) { for (FileObject fo : (Collection<FileObject>) jp.getInstallFolders()) { installedFolders.add(FileUtil.toFile(fo)); } } } initComponents(); platformsList.addMouseListener(checkListener); platformsList.addKeyListener(checkListener); }
public ToolTipList(ToolTipListDelegate delegate) { super(new BorderLayout()); this.delegate = delegate; tipsModel = new DefaultListModel(); tipsList = new JList(tipsModel); tipsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tipsList.setBackground(BACKGROUND_COLOR); tipsList.setSelectionForeground(Color.black); tipsList.setSelectionBackground(BACKGROUND_COLOR); tipsList.setPrototypeCellValue("This is a rule name g"); tipsList.addKeyListener(new MyListKeyAdapter()); tipsList.setFocusable(false); tipsScrollPane = new JScrollPane(tipsList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); tipsScrollPane.setFocusable(false); tipsScrollPane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); addMouseListener(new MyMouseAdapter()); add(tipsScrollPane, BorderLayout.CENTER); }
protected void installListeners(JFontChooser fc) { selectionPanelHandler = new SelectionPanelHandler(); selectionPanel.getCollectionList().addListSelectionListener(selectionPanelHandler); selectionPanel.getFamilyList().addListSelectionListener(selectionPanelHandler); selectionPanel.getFaceList().addListSelectionListener(selectionPanelHandler); selectionPanel.getCollectionList().addKeyListener(selectionPanelHandler); selectionPanel.getFamilyList().addKeyListener(selectionPanelHandler); selectionPanel.getFaceList().addKeyListener(selectionPanelHandler); selectionPanel.getCollectionList().addMouseListener(selectionPanelHandler); selectionPanel.getFamilyList().addMouseListener(selectionPanelHandler); selectionPanel.getFaceList().addMouseListener(selectionPanelHandler); chooserHandler = new FontChooserHandler(); fontChooser.addPropertyChangeListener(chooserHandler); if (fontChooser.getModel() != null) { fontChooser.getModel().addTreeModelListener(chooserHandler); } }
public JComponent overlayCreateInterface() { visibleMatchingRules = (isVStyle()?7:15); //if it's on all the time, better if there's less displayed on screen getTextComponent().addKeyListener(new MyKeyAdapter()); listModel = new DefaultListModel(); list = new JList(listModel) { public int getVisibleRowCount() { return Math.min(listModel.getSize(), visibleMatchingRules); } }; list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setBackground(new Color(235, 244, 254)); list.addKeyListener(new MyKeyAdapter()); list.setPrototypeCellValue("This is a rule name g"); list.addMouseListener(new ListMouseAdapter()); JScrollPane scrollPane = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); return scrollPane; }
/** * Have the panel register itself as a listener wherever it's needed. * <p/> * According to * http://www-106.ibm.com/developerworks/java/library/j-jtp0618.html it is a * major bad no-no to perform these registrations before the constructor * finishes, so this function has to be called after the panel is created. * Please note, this restriction only applies to listeners for objects that * aren't on the panel itself. */ public void initializeListeners() { clientgui.getClient().getGame().addGameListener(this); clientgui.getBoardView().addBoardViewListener(this); clientgui.bv.addKeyListener(this); // mech display. clientgui.mechD.wPan.weaponList.addListSelectionListener(this); clientgui.mechD.wPan.weaponList.addKeyListener(this); }