Java Code Examples for javax.swing.JList#getSelectedValue()
The following examples show how to use
javax.swing.JList#getSelectedValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFontChooser.java From PacketProxy with Apache License 2.0 | 6 votes |
public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { JList list = (JList) e.getSource(); String selectedValue = (String) list.getSelectedValue(); String oldValue = textComponent.getText(); textComponent.setText(selectedValue); if (!oldValue.equalsIgnoreCase(selectedValue)) { textComponent.selectAll(); textComponent.requestFocus(); } updateSampleFont(); } }
Example 2
Source File: TransportDetailPanel.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@Override public void valueChanged(ListSelectionEvent evt) { JList<?> transportList = (JList<?>) evt.getSource(); if (!transportList.getValueIsAdjusting()) { Transportable newTransportable = (Transportable) transportList.getSelectedValue(); if (newTransportable instanceof Resupply) { resupplyPanel.setResupply((Resupply) newTransportable); cardLayout.show(this, RESUPPLY); } else if (newTransportable instanceof ArrivingSettlement) { arrivingSettlementPanel.setArrivingSettlement((ArrivingSettlement) newTransportable); cardLayout.show(this, SETTLEMENT); } } }
Example 3
Source File: ResupplyWindow.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { JList<?> incomingList = (JList<?>) evt.getSource(); Object selected = incomingList.getSelectedValue(); if (selected != null) { // Incoming transport item is selected, // so enable modify and cancel buttons. modifyButton.setEnabled(true); cancelButton.setEnabled(true); } else { // Incoming transport item is unselected, // so disable modify and cancel buttons. modifyButton.setEnabled(false); cancelButton.setEnabled(false); } } }
Example 4
Source File: ConfigurableDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private ListSelectionListener createListSelectionListener(final JList<Configurable> list) { return new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } Configurable configurable = list.getSelectedValue(); updateParameterPanel(configurable); previousConfigurable = configurable; if (e.getSource() == list && configurable != null) { unselectAllOtherLists(configurable.getSource()); } updateButtonState(true); } }; }
Example 5
Source File: SampleListing.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
@Override public void valueChanged (ListSelectionEvent e) { JList<Sample> selectedList = (JList<Sample>) e.getSource(); Sample sample = selectedList.getSelectedValue(); if (e.getValueIsAdjusting()) { // Nullify selection in other lists for (Component comp : scrollablePanel.getComponents()) { ShapePane shapePane = (ShapePane) comp; JList<Sample> list = shapePane.list; if (list != selectedList) { list.clearSelection(); } } if (alt) { checkAlternative(sample); // Look for good alternative } } else if (sample != null) { browser.publishSample(sample); } }
Example 6
Source File: SampleListing.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
@Override public void mousePressed (MouseEvent e) { // { // JList<Sample> selectedList = (JList<Sample>) e.getSource(); // Point point = e.getPoint(); // int index = selectedList.locationToIndex(point); // logger.info("index:{}", index); // } // alt = e.isAltDown(); if (alt) { JList<Sample> selectedList = (JList<Sample>) e.getSource(); Sample sample = selectedList.getSelectedValue(); checkAlternative(sample); // Look for good alternative } }
Example 7
Source File: CheckListener.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_SPACE) { return; } if (!(e.getSource() instanceof JList)) { return; } JList list = (JList) e.getSource(); Object selected = list.getSelectedValue(); if (selected == null) { return; } toggle(selected); e.consume(); }
Example 8
Source File: EventsModel.java From netbeans with Apache License 2.0 | 6 votes |
private String selectListenerClass(JavaComponentInfo ci) { List<ReferenceType> attachableListeners = RemoteServices.getAttachableListeners(ci); //System.err.println("Attachable Listeners = "+attachableListeners); String[] listData = new String[attachableListeners.size()]; for (int i = 0; i < listData.length; i++) { listData[i] = attachableListeners.get(i).name(); } JList jl = new JList(listData); JScrollPane jsp = new JScrollPane(jl); NotifyDescriptor nd = new DialogDescriptor(jsp, NbBundle.getMessage(EventsModel.class, "TTL_SelectListener"), true, null); Object res = DialogDisplayer.getDefault().notify(nd); if (DialogDescriptor.OK_OPTION.equals(res)) { String clazz = (String) jl.getSelectedValue(); return clazz; } else { return null; } }
Example 9
Source File: PlayListPanel.java From aurous-app with GNU General Public License v2.0 | 6 votes |
@Override public void actionPerformed(final ActionEvent e) { final Component c = (Component) e.getSource(); final JPopupMenu popup = (JPopupMenu) c.getParent(); final JList<?> list = (JList<?>) popup.getInvoker(); final Object o = list.getSelectedValue(); final String playlist = o.toString(); switch (e.getActionCommand()) { case "Delete": Playlist.getPlaylist().deletePlayList(list); break; case "Play": ModelUtils.loadPlayList(playlist); PlayerFunctions.seekNext(); break; case "Load": ModelUtils.loadPlayList(playlist); break; case "Share": // System.out.println("Sharing"); break; } // System.out.println(table.getSelectedRow() + " : " + // table.getSelectedColumn()); }
Example 10
Source File: JFrameConf.java From mts with GNU General Public License v3.0 | 5 votes |
private void jListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListValueChanged this.showMessagesForChanges(); JList jList = (JList) evt.getSource(); String selectedValue = (String) jList.getSelectedValue(); // selectedValue = selectedValue + ".properties"; this.currentFile = selectedValue; try{ Config.getConfigByName(selectedValue).build(this.currentFile, false); } catch(Exception e){ GlobalLogger.instance().getApplicationLogger().error(TextEvent.Topic.CORE, e, "Cannot build in list"); } this.build(Config.getConfigByName(this.currentFile)); }
Example 11
Source File: PredefinedCrsPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(ListSelectionEvent e) { final JList list = (JList) e.getSource(); selectedCrsInfo = (CrsInfo) list.getSelectedValue(); if (selectedCrsInfo != null) { try { setInfoText(selectedCrsInfo.getDescription()); } catch (Exception e1) { String message = e1.getMessage(); if (message != null) { setInfoText("Error while creating CRS:\n\n" + message); } } } }
Example 12
Source File: MediaContentEditor.java From jclic with GNU General Public License v2.0 | 5 votes |
protected void selectBtnPressed() { String value = null; JList<Object> list = null; String dlgTitleKey = null; if (mc.mediaType == MediaContent.RUN_CLIC_ACTIVITY) { list = new JList<Object>(mbe.getProjectEditor().getActivityBagEditor().getListModel()); dlgTitleKey = "edit_mc_activity_selection"; } else if (mc.mediaType == MediaContent.RUN_CLIC_PACKAGE) { list = new JList<Object>(mbe.getProjectEditor().getActivitySequenceEditor().getTagList()); dlgTitleKey = "edit_mc_sequence_selection"; } if (list != null) { JScrollPane pane = new JScrollPane(list); if (options.getMessages().showInputDlg(this, pane, dlgTitleKey)) { Object o = list.getSelectedValue(); if (o != null) value = o.toString(); } } else { int filter = mc.mediaType == MediaContent.PLAY_AUDIO ? Utils.ALL_SOUNDS_FF : mc.mediaType == MediaContent.PLAY_MIDI ? Utils.MIDI_FF : mc.mediaType == MediaContent.PLAY_VIDEO ? Utils.ALL_VIDEO_FF : Utils.ALL_MULTIMEDIA_FF; value = MediaBagSelector.getMediaName(mc.mediaFileName, options, this, mbe, filter); } if (value != null) { mc.mediaFileName = value; fileTxt.setText(value); } }
Example 13
Source File: AbstractQuickSearchComboBar.java From netbeans with Apache License 2.0 | 5 votes |
/** Actually invokes action selected in the results list */ public void invokeSelectedItem () { JList list = displayer.getList(); ResultsModel.ItemResult ir = (ItemResult) list.getSelectedValue(); // special handling of invocation of "more results item" (three dots) if (ir != null) { Runnable action = ir.getAction(); if (action instanceof CategoryResult) { CategoryResult cr = (CategoryResult)action; evaluate(cr.getCategory()); return; } } // #137259: invoke only some results were found if (list.getModel().getSize() > 0) { returnFocus(false); // #137342: run action later to let focus indeed be transferred // by previous returnFocus() call SwingUtilities.invokeLater(new Runnable() { public void run() { displayer.invoke(); } }); } }
Example 14
Source File: ConfigurableDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private Configurable getSelectedValue() { if (!localConfigList.isSelectionEmpty()) { return localConfigList.getSelectedValue(); } else { for (JList<Configurable> list : remoteConfigLists.values()) { if (!list.isSelectionEmpty()) { return list.getSelectedValue(); } } } return null; }
Example 15
Source File: ContactGroupTransferHandler.java From Spark with Apache License 2.0 | 5 votes |
@Override public Transferable createTransferable(JComponent comp) { if (comp instanceof JList) { JList list = (JList)comp; ContactItem source = (ContactItem)list.getSelectedValue(); return new ContactItemTransferable(source); } return null; }
Example 16
Source File: ArrivedListPanel.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) { JList<?> incomingList = (JList<?>) evt.getSource(); if (incomingList.getSelectedValue() != null) { arrivedList.clearSelection(); } } }
Example 17
Source File: SelectTableInfoListener.java From HBaseClient with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void valueChanged(ListSelectionEvent e) { JList<String> v_Tables = (JList<String>)e.getSource(); String v_TableName = v_Tables.getSelectedValue(); if ( !JavaHelp.isNull(v_TableName) ) { if ( !v_TableName.equals(this.getTableName()) ) { this.getAppFrame().setTableName(v_TableName); } } }
Example 18
Source File: IncomingListPanel.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) { JList<?> arrivedList = (JList<?>) evt.getSource(); if (arrivedList.getSelectedValue() != null) { incomingList.clearSelection(); } } }
Example 19
Source File: TripleAFrame.java From triplea with GNU General Public License v3.0 | 5 votes |
/** * Prompts the user to select the territory on which they wish to conduct a rocket attack. * * @param candidates The collection of territories on which the user may conduct a rocket attack. * @param from The territory from which the rocket attack is conducted. * @return The selected territory or {@code null} if no territory was selected. */ public Territory getRocketAttack(final Collection<Territory> candidates, final Territory from) { messageAndDialogThreadPool.waitForAll(); mapPanel.centerOn(from); final Supplier<Territory> action = () -> { final JList<Territory> list = new JList<>(SwingComponents.newListModel(candidates)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); final JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JScrollPane scroll = new JScrollPane(list); panel.add(scroll, BorderLayout.CENTER); if (from != null) { panel.add(BorderLayout.NORTH, new JLabel("Targets for rocket in " + from.getName())); } final String[] options = {"OK", "Dont attack"}; final String message = "Select Rocket Target"; final int selection = JOptionPane.showOptionDialog( TripleAFrame.this, panel, message, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null); return (selection == 0) ? list.getSelectedValue() : null; }; return Interruptibles.awaitResult(() -> SwingAction.invokeAndWaitResult(action)) .result .orElse(null); }
Example 20
Source File: DbxFileActions.java From Open-LaTeX-Studio with MIT License | 5 votes |
/** * Shows a .tex files list from user's dropbox and opens the selected one * * @return List, that contatins user's .tex files from his dropbox; can be * empty */ public void openFromDropbox(DropboxRevisionsTopComponent drtc, RevisionDisplayTopComponent revtc) { List<DbxEntryDto> dbxEntries = getDbxTexEntries(DbxUtil.getDbxClient()); if (!dbxEntries.isEmpty()) { JList<DbxEntryDto> list = new JList(dbxEntries.toArray()); list.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); int option = JOptionPane.showConfirmDialog(null, list, "Open file from Dropbox", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION && !list.isSelectionEmpty()) { DbxEntryDto entry = list.getSelectedValue(); String localPath = ApplicationUtils.getAppDirectory() + File.separator + entry.getName(); File outputFile = DbxUtil.downloadRemoteFile(entry, localPath); revtc.close(); drtc.updateRevisionsList(entry.getPath()); drtc.open(); drtc.requestActive(); String content = FileService.readFromFile(outputFile.getAbsolutePath()); etc.setEditorContent(content); etc.setCurrentFile(outputFile); etc.getEditorState().setDbxState(new DbxState(entry.getPath(), entry.getRevision())); etc.getEditorState().setModified(false); etc.getEditorState().setPreviewDisplayed(false); } } else{ JOptionPane.showMessageDialog(etc, "No .tex files found!", "Error", JOptionPane.ERROR_MESSAGE); } }