List of usage examples for javax.swing JTable setUpdateSelectionOnSort
@BeanProperty(expert = true, description = "Whether or not to update the selection on sorting") public void setUpdateSelectionOnSort(boolean update)
From source file:net.sf.maltcms.chromaui.msviewer.ui.panel.MassSpectrumPanel.java
public void addIdentification() { // Create a custom NotifyDescriptor, specify the panel instance as a parameter + other params NotifyDescriptor nd = new NotifyDescriptor(ddp, // instance of your panel "Select Databases and Settings", // title of the dialog NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ... NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.OK_OPTION // default option is "Yes" );//w ww. ja va2 s .c om ddp.updateView(); // let's display the dialog now... if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) { if (ddp.getSelectedDatabases().isEmpty()) { return; } Runnable r = new Runnable() { @Override public void run() { IQuery<IScan> query = Lookup.getDefault().lookup(IQueryFactory.class).createQuery( ddp.getSelectedDatabases(), ddp.getRetentionIndexCalculator(), ddp.getSelectedMetabolitePredicate(), ddp.getMatchThreshold(), ddp.getMaxNumberOfHits(), ddp.getRIWindow(), seriesToScan.values().toArray(new IScan[seriesToScan.size()])); try { List<QueryResultList<IScan>> results = query.call(); Box outerBox = Box.createVerticalBox(); for (QueryResultList<IScan> mdqrl : results) { for (IQueryResult<IScan> result : mdqrl) { Box vbox = Box.createVerticalBox(); JLabel label = new JLabel("Results for scan " + result.getScan().getScanIndex() + " at " + result.getScan().getScanAcquisitionTime() + " with ri: " + result.getRetentionIndex()); JLabel dbLabel = new JLabel( "DB: " + result.getDatabaseDescriptor().getResourceLocation()); vbox.add(label); vbox.add(dbLabel); JLabel parameterLabel = new JLabel("Minimum Score: " + ddp.getMatchThreshold() + "; Maximum #Hits Returned: " + ddp.getMaxNumberOfHits()); vbox.add(parameterLabel); DefaultTableModel dlm = new DefaultTableModel( new String[] { "Score", "RI", "Name", "ID", "MW", "Formula", "Max Mass" }, 0); for (IMetabolite metabolite : result.getMetabolites()) { String name = metabolite.getName(); if (name.lastIndexOf("_") != -1) { name = name.substring(name.lastIndexOf("_") + 1); } dlm.addRow(new Object[] { result.getScoreFor(metabolite), result.getRiFor(metabolite), name, metabolite.getID(), metabolite.getMW(), metabolite.getFormula(), metabolite.getMaxMass() }); } JTable jl = new JTable(dlm); JScrollPane resultScrollPane = new JScrollPane(jl); jl.setAutoCreateRowSorter(true); jl.setUpdateSelectionOnSort(true); vbox.add(resultScrollPane); outerBox.add(vbox); outerBox.add(Box.createVerticalStrut(10)); } } JScrollPane jsp = new JScrollPane(outerBox); NotifyDescriptor nd = new NotifyDescriptor(jsp, // instance of your panel "Database Search Results", // title of the dialog NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ... NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.OK_OPTION // default option is "Yes" ); if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) { } //DBConnectionManager.close(); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } }; RequestProcessor.getDefault().post(r); } }