javax.swing.JList#getSelectedValue ( )源码实例Demo

下面列出了javax.swing.JList#getSelectedValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: aurous-app   文件: PlayListPanel.java
@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());
}
 
源代码2 项目: PacketProxy   文件: JFontChooser.java
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();
    }
}
 
源代码3 项目: netbeans   文件: EventsModel.java
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;
    }
}
 
源代码4 项目: netbeans   文件: CheckListener.java
@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();
}
 
源代码5 项目: audiveris   文件: SampleListing.java
@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
    }
}
 
源代码6 项目: audiveris   文件: SampleListing.java
@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);
    }
}
 
源代码7 项目: rapidminer-studio   文件: ConfigurableDialog.java
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);
		}
	};
}
 
源代码8 项目: mars-sim   文件: ResupplyWindow.java
@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);
		}
	}
}
 
源代码9 项目: mars-sim   文件: TransportDetailPanel.java
@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);
		}
	}
}
 
源代码10 项目: HBaseClient   文件: SelectTableInfoListener.java
@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);
        }
    }
}
 
源代码11 项目: netbeans   文件: AbstractQuickSearchComboBar.java
/** 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();
                }
        });
    }
}
 
源代码12 项目: mts   文件: JFrameConf.java
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));
    }
 
源代码13 项目: snap-desktop   文件: PredefinedCrsPanel.java
@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);
            }
        }
    }
}
 
源代码14 项目: jclic   文件: MediaContentEditor.java
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);
  }
}
 
源代码15 项目: rapidminer-studio   文件: ConfigurableDialog.java
private Configurable getSelectedValue() {

		if (!localConfigList.isSelectionEmpty()) {
			return localConfigList.getSelectedValue();
		} else {
			for (JList<Configurable> list : remoteConfigLists.values()) {
				if (!list.isSelectionEmpty()) {
					return list.getSelectedValue();
				}
			}
		}
		return null;
	}
 
源代码16 项目: Spark   文件: ContactGroupTransferHandler.java
@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;
   }
 
源代码17 项目: mars-sim   文件: ArrivedListPanel.java
@Override
public void valueChanged(ListSelectionEvent evt) {
	if (evt.getValueIsAdjusting()) {
		JList<?> incomingList = (JList<?>) evt.getSource();
		if (incomingList.getSelectedValue() != null) {
			arrivedList.clearSelection();
		}
	}
}
 
源代码18 项目: mars-sim   文件: IncomingListPanel.java
@Override
public void valueChanged(ListSelectionEvent evt) {
	if (evt.getValueIsAdjusting()) {
		JList<?> arrivedList = (JList<?>) evt.getSource();
		if (arrivedList.getSelectedValue() != null) {
			incomingList.clearSelection();
		}
	}
}
 
源代码19 项目: triplea   文件: TripleAFrame.java
/**
 * 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);
}
 
源代码20 项目: Open-LaTeX-Studio   文件: DbxFileActions.java
/**
 * 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);
    }
}