List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel
public DefaultTableModel()
DefaultTableModel
which is a table of zero columns and zero rows. From source file:GeMSE.GS.Analysis.Stats.OneSampleCovariancePanel.java
private void GridView(double[][] matrix) { DefaultTableModel spaceTabMod = new DefaultTableModel() { @Override/*from w ww . j a v a 2 s . co m*/ public boolean isCellEditable(int row, int column) { return false; } }; String[] columnTitle = new String[matrix[0].length + 1]; columnTitle[0] = ""; for (int col = 1; col < columnTitle.length; col++) columnTitle[col] = "Column " + String.valueOf(col); spaceTabMod.setColumnIdentifiers(columnTitle); int col = 0; for (int r = 0; r < matrix.length; r++) { String[] row = new String[matrix[0].length + 1]; row[0] = "Row " + Integer.toString(r); for (col = 0; col < matrix[0].length; col++) row[col + 1] = Double.toString(matrix[r][col]); spaceTabMod.addRow(row); } matrixDG.setModel(spaceTabMod); matrixDG.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); matrixDG.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); ResizeColumnWidth(matrixDG); }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatMultiplePanel.java
/** * @return//from w w w . j a v a 2 s . co m */ private DefaultTableModel getCleanTableModel() { DefaultTableModel model = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { return (column != 1); } }; model.addColumn(FIELD_VALUE_COL); model.addColumn(DISPLAY_FORMAT_COL); model.addColumn(ELLIPSIS_BUTTON_COL); addTableModelListener(model); return model; }
From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java
@Override protected void showAlternativeView() { final TableModel model; if (profileData != null) { model = createProfileDataTableModel(); } else {/*from ww w . j a v a 2s .co m*/ model = new DefaultTableModel(); } final TableViewPagePanel alternativePanel = (TableViewPagePanel) getAlternativeView(); alternativePanel.setModel(model); super.showAlternativeView(); }
From source file:boundary.ReportProduce.java
public void setTable() { DefaultTableModel model = new DefaultTableModel(); jTable1.setModel(model);// ww w. j ava 2 s. c o m model.addColumn("No."); model.addColumn("Title"); model.addColumn("Status"); model.addColumn("Recording Session No."); model.addColumn("Recording Date"); for (Map.Entry<Integer, ArrayList<Object>> entry : ReportProduceControl .getRecordings(String.valueOf(jComboBox1.getSelectedItem())).entrySet()) { Integer key = entry.getKey(); ArrayList<Object> value = entry.getValue(); value.add(0, key); model.addRow(value.toArray()); } jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (jTable1.getSelectedRow() > -1) { setSoundmanTbl((String) jTable1.getValueAt(jTable1.getSelectedRow(), 3)); setMusicianTbl((String) jTable1.getValueAt(jTable1.getSelectedRow(), 3)); } } }); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDoseResponseController.java
/** * Reset views on cancel// w w w. ja v a 2 s . c om */ @Override public void resetOnCancel() { super.resetOnCancel(); loadGenericDRDataController.reset(); dRInputController.reset(); importedDRDataHolder = null; setFirstFitting(true); getCardLayout().first(genericDRParentPanel.getContentPanel()); onCardSwitch(); genericDRParentPanel.getCancelButton().setEnabled(false); dRAnalysisGroup = null; //remove tables, graphs and subpanels dRInputController.getdRInputPanel().getSlopesTable().setModel(new DefaultTableModel()); dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); //set view back to first one dRPanel.getInputDRButton().setSelected(true); dRPanel.revalidate(); dRPanel.repaint(); }
From source file:latexstudio.editor.DropboxRevisionsTopComponent.java
public void updateRevisionsList(String path) { DbxClient client = DbxUtil.getDbxClient(); List<DbxEntry.File> entries = null; if (path != null) { try {/*from ww w.ja v a 2 s.c o m*/ entries = client.getRevisions(path); } catch (DbxException ex) { DbxUtil.showDbxAccessDeniedPrompt(); } } dlm.clear(); DefaultTableModel model = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return column == REVIEW_COLUMN; } }; model.addColumn(REVISION_COLUMN_NAME); model.addColumn(MODIFIED_COLUMN_NAME); model.addColumn(FILE_SIZE_COLUMN_NAME); model.addColumn(REVIEW_COLUMN_NAME); if (entries != null && entries.size() > 0) { for (DbxEntry.File dbxEntry : entries) { dlm.addElement(new DbxEntryRevision(dbxEntry)); model.addRow(new Object[] { dbxEntry.rev, dbxEntry.lastModified, dbxEntry.humanSize, REVIEW_BUTTON_LABEL }); } } Action showVersion = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // Resolving which row has been double-clicked JTable table = (JTable) e.getSource(); int row = Integer.valueOf(e.getActionCommand()); // Finding revision using information from the clicked row String revisionNumber = table.getValueAt(row, REVISION_COLUMN).toString(); loadRevision(revisionNumber); } }; jTable1.setModel(model); ButtonColumn buttonColumn = new ButtonColumn(jTable1, showVersion, REVIEW_COLUMN); buttonColumn.setMnemonic(KeyEvent.VK_D); }
From source file:boundary.ReportProduce.java
private void setSoundmanTbl(String session) { DefaultTableModel model = new DefaultTableModel(); jTable2.setModel(model);/*w w w. j av a 2 s.co m*/ model.addColumn("ID"); model.addColumn("Producer"); model.addColumn("Mix Tech"); model.addColumn("Master Tech"); for (SoundManInSession entry : ReportProduceControl.getSoundmans(Integer.valueOf(session))) { model.addRow(new Object[] { entry.getSoundManID(), entry.isProducer(), entry.isMasterTech(), entry.isMasterTech() }); } }
From source file:com.dvd.ui.UpdateBooking.java
private void populateTable() { getData();/* w w w .j a v a 2s . c o m*/ DefaultTableModel model = new DefaultTableModel(); model.setColumnIdentifiers(new String[] { "Booking ID", "User ID", "DVD Copy Number", "Added Date " }); bookingTable.setModel(new DefaultTableModel()); for (Booking booking_item : bookingList) { model.addRow(new String[] { String.valueOf(booking_item.getId()), String.valueOf(booking_item.getUserID()), String.valueOf(booking_item.getCopyNumber()), String.valueOf(booking_item.getBookingAddedDate()) }); } bookingTable.setModel(model); }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override// www .j av a2 s.c o m public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:org.pgptool.gui.ui.keyslist.KeysTableView.java
@Override protected void internalUnbindFromPm() { super.internalUnbindFromPm(); table.setModel(new DefaultTableModel()); ctxMenu.removeAll();//from w w w . j a va 2 s . c om }