public int getSelectedIndex() { return list.getSelectedIndex(); }
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Object getValue() { if (canceled == true) { return originalValue; } final int selectedIndex = iconList.getSelectedIndex(); if ((0 <= selectedIndex) && (selectedIndex < orderedKeyList.size())) return orderedKeyList.get(selectedIndex); else return originalValue; }
private Session selectedSession() { return listModel.getElementAt(list.getSelectedIndex()); }
void repaintList() { list.repaint(list.getCellBounds(list.getSelectedIndex(), list.getSelectedIndex())); }
/** * Returns the value for the smallest selected cell index; * <i>the selected value</i> when only a single item is selected in the * list. When multiple items are selected, it is simply the value for the * smallest selected index. Returns {@code null} if there is no selection. * <p> * This is a convenience method that simply returns the model value for * {@code getMinSelectionIndex}, taking into account sorting and filtering. * * @return the first selected value * @see #getMinSelectionIndex * @see #getModel * @see #addListSelectionListener */ @Override public Object getSelectedValue() { int i = getSelectedIndex(); return (i == -1) ? null : getElementAt(i); }
/** * Returns the value for the smallest selected cell index; * <i>the selected value</i> when only a single item is selected in the * list. When multiple items are selected, it is simply the value for the * smallest selected index. Returns {@code null} if there is no selection. * <p> * This is a convenience method that simply returns the model value for * {@code getMinSelectionIndex}, taking into account sorting and filtering. * * @return the first selected value * @see #getMinSelectionIndex * @see #getModel * @see #addListSelectionListener */ @Override public Object getSelectedValue() { int i = getSelectedIndex(); return (i == -1) ? null : getElementAt(i); }
/** * Returns the value for the smallest selected cell index; * <i>the selected value</i> when only a single item is selected in the * list. When multiple items are selected, it is simply the value for the * smallest selected index. Returns {@code null} if there is no selection. * <p> * This is a convenience method that simply returns the model value for * {@code getMinSelectionIndex}, taking into account sorting and filtering. * * @return the first selected value * @see #getMinSelectionIndex * @see #getModel * @see #addListSelectionListener */ @Override public Object getSelectedValue() { int i = getSelectedIndex(); return (i == -1) ? null : getElementAt(i); }
/** * Returns the value for the smallest selected cell index; * <i>the selected value</i> when only a single item is selected in the * list. When multiple items are selected, it is simply the value for the * smallest selected index. Returns {@code null} if there is no selection. * <p> * This is a convenience method that simply returns the model value for * {@code getMinSelectionIndex}, taking into account sorting and filtering. * * @return the first selected value * @see #getMinSelectionIndex * @see #getModel * @see #addListSelectionListener */ @Override public Object getSelectedValue() { int i = getSelectedIndex(); return (i == -1) ? null : getElementAt(i); }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectPreviousIndex() { int s = list.getSelectedIndex(); if(s > 0) { s -= 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectPreviousIndex() { int s = list.getSelectedIndex(); if(s > 0) { s -= 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectPreviousIndex() { int s = list.getSelectedIndex(); if(s > 0) { s -= 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectPreviousIndex() { int s = list.getSelectedIndex(); if(s > 0) { s -= 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
@Override public void actionPerformed(ActionEvent e) { final Session selectedSession = selectedSession(); final String initialSelectionValue = selectedSession.getName(); final String newName = (String) showInputDialog(panel, "Rename session", "Enter new name for session", PLAIN_MESSAGE, null, null, initialSelectionValue); if (newName != null && !newName.equals(initialSelectionValue)) { final List<Session> sessions = listModel.getList(); final boolean present = sessions.stream().map(Session::getName).anyMatch(s -> s.equals(newName)); if (present) { final int confirm = JOptionPane.showConfirmDialog(panel, "Do you want to override session \"" + newName + "\"", "Confirm", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.NO_OPTION) { return; } } listModel.change(list.getSelectedIndex(), new Session(newName, selectedSession.getFilesToOpen())); } } };
@Override public void actionPerformed(ActionEvent e) { final int i = JOptionPane.showConfirmDialog( SessionsConfig.this.getView(), "Do you want to delete session " + selectedSession().getName(), "Confirm", JOptionPane.YES_NO_OPTION ); if (i == JOptionPane.YES_OPTION) { listModel.remove(list.getSelectedIndex()); } } };
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectNextIndex() { int s = list.getSelectedIndex(); if((s + 1) < getElementCount()) { s += 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectNextIndex() { int s = list.getSelectedIndex(); if((s + 1) < getElementCount()) { s += 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectNextIndex() { int s = list.getSelectedIndex(); if((s + 1) < getElementCount()) { s += 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
/** * Selected the previous row and force it to be visible. * * @see JList#ensureIndexIsVisible */ protected void selectNextIndex() { int s = list.getSelectedIndex(); if((s + 1) < getElementCount()) { s += 1; list.setSelectedIndex(s); list.ensureIndexIsVisible(s); } }
private void updateState() { boolean empty = listModel.getSize() == 0; boolean selected = list.getSelectedIndex() > -1; renameAction.setEnabled(!empty && selected); deleteAction.setEnabled(!empty && selected); if (empty) { sessionFilesTextArea.setText(""); } if (selected && !empty && list.getSelectedIndex() < listModel.getSize()) { final Session session = selectedSession(); sessionFilesTextArea.setText(SessionUtil.toStringGroupedByServer(session)); } else { sessionFilesTextArea.setText(""); } }
/** * Shows the annotation pane in a dialog. * * @param parentComponent the parent component. * @param title the title of the dialog. * @param okButtonText the text to show on the OK button. * @return the chosen interpreter. */ protected E showDialog(Component parentComponent, String title, String okButtonText) { if (OptionPanes.showInputDialog(parentComponent, this, textField, title, okButtonText, UIManager.getString("OptionPane.cancelButtonText"))) { int modelIndex; if (list.getRowSorter().getViewRowCount() == 1) { modelIndex = list.convertIndexToModel(0); } else { modelIndex = list.convertIndexToModel(list.getSelectedIndex()); } return safeCast(list.getModel().getElementAt(modelIndex)); } else { return null; } }