Java Code Examples for javax.swing.event.ListSelectionEvent#getSource()
The following examples show how to use
javax.swing.event.ListSelectionEvent#getSource() .
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: FileServiceApp.java From micro-integrator with Apache License 2.0 | 6 votes |
public void valueChanged(ListSelectionEvent e) { Object src = e.getSource(); if (e.getValueIsAdjusting()) { return; } if (src == this.filesList) { if (this.filesList.getSelectedValues().length == 0) { this.setInfoText(null, null, null); return; } Object fileNameObj = this.filesList.getSelectedValue(); if (fileNameObj != null) { this.doFileSelectionChange(fileNameObj.toString()); } } }
Example 2
Source File: VanitygenPanel.java From bither-desktop-java with Apache License 2.0 | 6 votes |
@Override public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (!lsm.isSelectionEmpty()) { int minIndex = lsm.getMinSelectionIndex(); int maxIndex = lsm.getMaxSelectionIndex(); for (int i = minIndex; i <= maxIndex; i++) { if (lsm.isSelectedIndex(i)) { selectedDevice = devices.get(i); break; } } if (selectedDevice != null) { cbxCPU.setSelected(false); cbxGPU.setSelected(true); } selectDeviceTableModel.fireTableDataChanged(); } }
Example 3
Source File: InterpolatingLookupPaintScaleSetupDialog.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) event.getSource(); int index = lsm.getLeadSelectionIndex(); if (index < 0) { return; } Double value = lookupTable.keySet().toArray(new Double[0])[index]; Color color = lookupTable.get(value); fieldValue.setValue(value); buttonColor.setBackground(color); }
Example 4
Source File: ChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void valueChanged(ListSelectionEvent e) { if (availTable != null && !e.getValueIsAdjusting()) { if (e.getSource() == availTable.getSelectionModel() && availTable.getSelectedObject() instanceof InfoFacade) { InfoFacade target = (InfoFacade) availTable.getSelectedObject(); InfoFactory factory = chooser.getInfoFactory(); if (factory != null && target != null) { infoPane.setText(factory.getHTMLInfo(target)); } } } }
Example 5
Source File: ShowTransactionsForm.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { showTransactionDetailsAction.setEnabled(false); showTransactionsButton.invalidate(); showTransactionsButton.validate(); showTransactionsButton.repaint(); } else { // Find out which indexes are selected. int minIndex = lsm.getMinSelectionIndex(); int maxIndex = lsm.getMaxSelectionIndex(); for (int i = minIndex; i <= maxIndex; i++) { if (lsm.isSelectedIndex(i)) { showTransactionDetailsAction.setEnabled(true); showTransactionsButton.invalidate(); showTransactionsButton.validate(); showTransactionsButton.repaint(); break; } } } }
Example 6
Source File: ComponentController.java From swingsane with Apache License 2.0 | 6 votes |
private void scannerListSelectionChanged(ListSelectionEvent e) { if (!(e.getValueIsAdjusting())) { return; } @SuppressWarnings("unchecked") JList<ScannerListItem> scannerList = (JList<ScannerListItem>) e.getSource(); if (scannerList.getSelectedIndex() < 0) { disableSettingsComponents(); disableScanButtons(); return; } disableSettingsComponents(); ScannerListItem scannerListItem = scannerList.getSelectedValue(); Scanner scanner = scannerListItem.getScanner(); adjustSettingsComponents(scanner); enableScanButtons(); updateComponents(scannerListItem); }
Example 7
Source File: ListSelectionDocument.java From blog with Apache License 2.0 | 6 votes |
@Override public void valueChanged(ListSelectionEvent e) { JList<?> list = (JList<?>) e.getSource(); ListModel<?> model = list.getModel(); ListSelectionModel listSelectionModel = list.getSelectionModel(); int minSelectionIndex = listSelectionModel.getMinSelectionIndex(); int maxSelectionIndex = listSelectionModel.getMaxSelectionIndex(); StringBuilder textBuilder = new StringBuilder(); for (int i = minSelectionIndex; i <= maxSelectionIndex; i++) { if (listSelectionModel.isSelectedIndex(i)) { Object elementAt = model.getElementAt(i); formatElement(elementAt, textBuilder, i); } } setText(textBuilder.toString()); }
Example 8
Source File: SampleAnalysisWorkflowManagerLAICPMS.java From ET_Redux with Apache License 2.0 | 5 votes |
public void valueChanged(ListSelectionEvent evt) { // When the user release the mouse button and completes the selection, // getValueIsAdjusting() becomes false if (!evt.getValueIsAdjusting()) { JList list = (JList) evt.getSource(); aliquotName_text.setText((String) list.getSelectedValue()); // decide if empty else process aliquot by name AliquotInterface aliquot = mySample.getAliquotByName((String) list.getSelectedValue()); if (aliquot != null) { if (myCurrentAliquot != null) { saveAliquot(myCurrentAliquot); } myCurrentAliquot = aliquot; initAliquot(aliquot); addAliquot_button.setEnabled(false); editAliquot_button.setEnabled(false); } else { // we got no aliquots fastEdits_panel.removeAll(); fastEdits_panel.repaint(); aliquotName_text.setText("Aliquot Name"); addAliquot_button.setEnabled(true); editAliquot_button.setEnabled(false); } } }
Example 9
Source File: EditIDSControlPanel.java From VanetSim with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(ListSelectionEvent arg0) { @SuppressWarnings("unchecked") JList<Object> list = (JList<Object>) arg0.getSource(); if(!list.getValueIsAdjusting() && list.getSelectedIndex() != -1){ if(list.getModel().equals(availableRulesModel)){ updateList("available", availableRulesModel.get(list.getSelectedIndex()).toString()); } else if (list.getModel().equals(selectedRulesModel)){ updateList("selected", selectedRulesModel.get(list.getSelectedIndex()).toString()); } } }
Example 10
Source File: SampleAnalysisWorkflowManagerIDTIMS.java From ET_Redux with Apache License 2.0 | 5 votes |
public void valueChanged(ListSelectionEvent evt) { // When the user release the mouse button and completes the selection, // getValueIsAdjusting() becomes false if (!evt.getValueIsAdjusting()) { JList list = (JList) evt.getSource(); aliquotName_text.setText((String) list.getSelectedValue()); // decide if empty else process aliquot by name AliquotInterface aliquot = mySample.getAliquotByName((String) list.getSelectedValue()); if (aliquot != null) { if (myCurrentAliquot != null) { saveAliquot(myCurrentAliquot); } myCurrentAliquot = aliquot; initAliquot(aliquot); addAliquot_button.setEnabled(false); editAliquot_button.setEnabled(false); } else { // we got no aliquots fastEdits_panel.removeAll(); fastEdits_panel.repaint(); aliquotName_text.setText("Aliquot Name"); addAliquot_button.setEnabled(true); editAliquot_button.setEnabled(false); } } }
Example 11
Source File: FileSelectionManager.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) // because of hint on on http://www.chka.de/swing/table/faq.html return; List<CardFile> selectedFiles = new ArrayList<CardFile>(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { // use the currently selected category files as fallback if the current table-selection is empty informListeners(curCategoryFiles); } else { // Find out which indices are selected. int minIndex = lsm.getMinSelectionIndex(); int maxIndex = lsm.getMaxSelectionIndex(); // determine the set of selected files for (int i = minIndex; i <= maxIndex; i++) { if (lsm.isSelectedIndex(i)) { selectedFiles.add(cardFileTable.getSortedRowFile(i)); } } // inform all listeners about the changed selection informListeners(selectedFiles); } }
Example 12
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 13
Source File: XMLMerger.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
public void valueChanged(ListSelectionEvent listSelectionEvent) { if (listSelectionEvent.getSource() == linkingList) { linkButton.setEnabled(false); unlinkButton.setEnabled(true); } else if (listSelectionEvent.getSource() == XMLViewer1.getIdElementList() || listSelectionEvent.getSource() == XMLViewer2.getIdElementList()) { if (XMLViewer1.getIdElementList().getSelectedIndex() != -1 && XMLViewer2.getIdElementList().getSelectedIndex() != -1) { linkButton.setEnabled(true); } } }
Example 14
Source File: DetailPanel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** @see ListSelectionListener **/ public void valueChanged(ListSelectionEvent aEvent) { //Ignore extra messages. if (aEvent.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) aEvent.getSource(); if (lsm.isSelectionEmpty()) { mDetails.setText("Nothing selected"); } else { final int selectedRow = lsm.getMinSelectionIndex(); final EventDetails e = mModel.getEventDetails(selectedRow); final Object[] args = { new Date(e.getTimeStamp()), e.getPriority(), escape(e.getThreadName()), escape(e.getNDC()), escape(e.getCategoryName()), escape(e.getLocationDetails()), escape(e.getMessage()), escape(getThrowableStrRep(e)) }; mDetails.setText(FORMATTER.format(args)); mDetails.setCaretPosition(0); } }
Example 15
Source File: SecurityRoleMappingPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Implementation of the ListSelectionListener interface */ public void valueChanged(ListSelectionEvent listSelectionEvent) { if(!listSelectionEvent.getValueIsAdjusting()) { Object source = listSelectionEvent.getSource(); if(source instanceof ListSelectionModel) { ListSelectionModel selectionModel = (ListSelectionModel) source; if(jTblPrincipals.getSelectionModel() == selectionModel) { enablePrincipalButtons(); } else if(jTblGroups.getSelectionModel() == selectionModel) { enableGroupButtons(); } } } }
Example 16
Source File: ClassInfoHandler.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { TreePath path; if (e.getSource() == availableTable.getSelectionModel()) { path = availableTable.getTree().getSelectionPath(); } else { path = selectedTable.getTree().getSelectionPath(); } if (path == null) { return; } PCClass c = null; DefaultMutableTreeNode treenode = (DefaultMutableTreeNode) path.getLastPathComponent(); Object[] objs = treenode.getUserObjectPath(); for (Object object : objs) { if (object instanceof PCClass) { c = (PCClass) object; break; } } if (c != null) { text = character.getSpellSupport().getClassInfo(c); classPane.setText(text); } } }
Example 17
Source File: ItemSelector.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void valueChanged (ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (e.getSource() == panel.list.getSelectionModel()) { changeSupport.fireChange(); } } }
Example 18
Source File: UseSpecificCatchCustomizer.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void valueChanged(ListSelectionEvent lse) { JList lst = (JList)lse.getSource(); boolean sel = lst.isEnabled() && !lst.isSelectionEmpty(); btnRemoveGeneric.setEnabled(sel); }
Example 19
Source File: RevisionDialogController.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void valueChanged (ListSelectionEvent e) { if (!e.getValueIsAdjusting() && e.getSource() == panel.lstBranches) { selectedBranchChanged(); } }
Example 20
Source File: EditVariablePanel.java From KEEL with GNU General Public License v3.0 | 4 votes |
@Override public void valueChanged(ListSelectionEvent e) { // If cell selection is enabled, both column and column change events are fired if (!e.getValueIsAdjusting() && e.getSource() == jTable1.getSelectionModel() && jTable1.getRowSelectionAllowed() && jTable1.getColumnSelectionAllowed()) { // Row selection changed ListSelectionModel csm = (ListSelectionModel) e.getSource(); if (!csm.isSelectionEmpty()) { deletejButton.setEnabled(true); int row = csm.getMinSelectionIndex(); if (row >= 0) { if (editDataPanel.getData().getAttributeTypeIndex(row).equalsIgnoreCase("nominal")) { nominalValuejLabel.setEnabled(true); nominalValuejTextField.setEnabled(true); rangeNominaljComboBox.setEnabled(true); addNominalValuejButton.setEnabled(true); deleteNominalValuejButton.setEnabled(true); valueRangejLabel.setEnabled(false); minjTextField.setEnabled(false); comajLabel.setEnabled(false); maxjTextField.setEnabled(false); rightBracketjLabel.setEnabled(false); leftBracketjLabel.setEnabled(false); changejButton.setEnabled(false); rangeNominaljComboBox.removeAllItems(); for (int i = 0; i < editDataPanel.getData().getRange(row).size(); i++) { rangeNominaljComboBox.addItem(new String(editDataPanel.getData().getRangesEnum(row, i))); } } else { nominalValuejLabel.setEnabled(false); nominalValuejTextField.setEnabled(false); rangeNominaljComboBox.setEnabled(false); addNominalValuejButton.setEnabled(false); deleteNominalValuejButton.setEnabled(false); valueRangejLabel.setEnabled(true); minjTextField.setEnabled(true); comajLabel.setEnabled(true); maxjTextField.setEnabled(true); rightBracketjLabel.setEnabled(true); leftBracketjLabel.setEnabled(true); changejButton.setEnabled(true); if (editDataPanel.getData().getAttributeTypeIndex(row).equalsIgnoreCase("integer")) { minjTextField.setText(editDataPanel.getData().getRangesInt(row, 0).toString()); maxjTextField.setText(editDataPanel.getData().getRangesInt(row, 1).toString()); } else { minjTextField.setText(editDataPanel.getData().getRangesReal(row, 0).toString()); maxjTextField.setText(editDataPanel.getData().getRangesReal(row, 1).toString()); } } } } else { } } else // e.getValueIsAdjusting() --> true. Se estan metiendo datos en una variable nueva { // } }