List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:UI.MainUI.java
private void fillTable(String[] tableRowData, int row) { DefaultTableModel model = (DefaultTableModel) forecastTable.getModel(); if (row >= forecastTable.getRowCount()) model.addRow(new Object[] { "", "", "", "", "" }); forecastTable.setValueAt(tableRowData[DATE_COL], row, DATE_COL); forecastTable.setValueAt(tableRowData[INPUT_COL], row, INPUT_COL); forecastTable.setValueAt(tableRowData[EXPECTED_OUTPUT_COL], row, EXPECTED_OUTPUT_COL); forecastTable.setValueAt(tableRowData[ACTUAL_OUTPUT_COL], row, ACTUAL_OUTPUT_COL); }
From source file:com.dvd.ui.SearchDVD.java
private void getDvdBtnActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_getDvdBtnActionPerformed String dvdCodeStr = dvdCodeTxt.getText(); errorLabelReserve.setVisible(false); copyTable.setVisible(false);// w w w .jav a 2 s. c o m copyTable.setModel(new DefaultTableModel()); boolean isMatched = false; DefaultTableModel model = new DefaultTableModel(); model.setColumnIdentifiers(new String[] { "Copy Number", "ISLE Number", "Shelf Number", "is Available " }); if (dvdCodeStr != null && !dvdCodeStr.isEmpty()) { int dvdCodeInt = 0; try { dvdCodeInt = Integer.parseInt(dvdCodeStr); // Get DVD Service for (Dvd dvd : searchDVDList) { if (dvd.getCode() == dvdCodeInt) { isMatched = true; jLabelDVDCode.setText(String.valueOf(dvd.getCode())); jLabelDVDCode1.setText(String.valueOf(dvd.getCode())); jLabelDVDTitle.setText(dvd.getTitle()); jLabelDVDTitle1.setText(dvd.getTitle()); jLabelYear.setText(String.valueOf(dvd.getYear())); jLabelImdb.setText(String.valueOf(dvd.getRating())); jLabelActors.setText(dvd.getActors()); jLabelFormat.setText(dvd.getDefiniiton()); // Get Copies from DVD code - Service DVDRepository dVDRepository = new DVDRepository(); try { if (isServiceOn) { searchCopyDVDList = new ArrayList<DvdCopy>(); searchCopyDVDList = dVDRepository.getCopyDVDList(dvdCodeInt); } else { com.dvd.hibernate.repo.DVDRepository repository = new com.dvd.hibernate.repo.DVDRepository(); searchCopyDVDList = new ArrayList<DvdCopy>(); List<DVDCopyDao> s = repository.getCopyDVDList(dvdCodeInt); if (s != null) { for (DVDCopyDao dvdCopyDao : s) { searchCopyDVDList.add(new DvdCopy(dvdCopyDao.getIsleNumber(), String.valueOf(dvdCopyDao.getCopyNumber()), dvdCopyDao.getShelfNumber(), dvd, dvdCopyDao.isAvailable())); } } } } catch (Exception ex) { Logger.getLogger(SearchDVD.class.getName()).log(Level.SEVERE, null, ex); } for (DvdCopy copy : searchCopyDVDList) { model.addRow(new String[] { copy.getCopyNumber(), copy.getIsleNumber(), copy.getShelfNumber(), String.valueOf(copy.isIsAvailable()) }); } jLabelCopies.setText(String.valueOf(searchCopyDVDList.size())); copyTable.setVisible(true); copyTable.setModel(model); } } if (!isMatched) { errorLabelReserve.setVisible(true); errorLabelReserve.setText("No DVD match"); } } catch (Exception e) { errorLabelReserve.setText(""); errorLabelReserve.setVisible(true); errorLabelReserve.setText("Please enter a valid DVD Code"); resetData(); } } else { resetData(); errorLabelReserve.setVisible(true); errorLabelReserve.setText("Please enter a valid DVD Code"); } }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
public void doExport() { //build attack table DefaultTableModel model = (DefaultTableModel) jAttackExportTable.getModel(); int rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0);//from ww w. j av a2s . co m } Iterator<String> plans = AttackManager.getSingleton().getGroupIterator(); while (plans.hasNext()) { String next = plans.next(); model.addRow(new Object[] { next, Boolean.FALSE }); } //build marker set table String[] sets = MarkerManager.getSingleton().getGroups(); model = (DefaultTableModel) jMarkerSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : sets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build report set table String[] reportSets = ReportManager.getSingleton().getGroups(); model = (DefaultTableModel) jReportSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : reportSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build troop table String[] troopSets = TroopsManager.getSingleton().getGroups(); model = (DefaultTableModel) jTroopSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : troopSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build note table String[] noteSets = NoteManager.getSingleton().getGroups(); model = (DefaultTableModel) jNoteSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : noteSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } jExportDialog.setAlwaysOnTop(true); jExportDialog.setVisible(true); }
From source file:semaforo.Semaforo.java
public void setUp() { this.setTitle("Semaforo"); URL hj = getClass().getResource("resources/semaforo.png"); setIconImage(Toolkit.getDefaultToolkit().getImage(hj)); listener = new UpdateTableListener() { @Override//from w w w . jav a 2s .c o m public void addTickers() { // Add in Tickers Table Settings settings = Controller.getSettings(); synchronized (updateLock) { update = 1; } CustomRenderer cr = new CustomRenderer(TableTicker.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); TableTicker.setDefaultRenderer(Object.class, cr); DefaultTableModel model = (DefaultTableModel) TableTicker.getModel(); Object[] o = new Object[2]; for (int i = model.getRowCount(); i < settings.getTickers().size(); i++) { o[0] = settings.getTickers().get(i).getName(); o[1] = 0; model.addRow(o); } // Resize the vector of values num_positions = Controller.getSettings().getTickers().size(); num_positions++; // Add in Week Tables CustomRenderer cr1 = new CustomRenderer(TableWeek1.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); CustomRenderer cr2 = new CustomRenderer(TableWeek2.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); CustomRenderer cr3 = new CustomRenderer(TableWeek3.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); // Table Week 1 TableWeek1.setDefaultRenderer(Object.class, cr1); DefaultTableModel model1 = (DefaultTableModel) TableWeek1.getModel(); Object[] o1 = new Object[10]; // Table Week 2 TableWeek2.setDefaultRenderer(Object.class, cr2); DefaultTableModel model2 = (DefaultTableModel) TableWeek2.getModel(); Object[] o2 = new Object[10]; // Table Week 3 TableWeek3.setDefaultRenderer(Object.class, cr3); DefaultTableModel model3 = (DefaultTableModel) TableWeek3.getModel(); Object[] o3 = new Object[10]; for (int i = model1.getRowCount(); i < settings.getTickers().size(); i++) { model1.addRow(o1); model2.addRow(o2); model3.addRow(o3); } synchronized (updateLock) { update = 0; } } @Override public boolean canUpdate() { return update == 1; } @Override public void stopThread() { synchronized (updateLock) { update = 2; } } @Override public void updateTickers() { synchronized (updateLock) { Settings settings = Controller.getSettings(); update = 2; CustomRenderer cr = new CustomRenderer(TableTicker.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); TableTicker.setDefaultRenderer(Object.class, cr); for (int i = 0; i < settings.getTickers().size(); i++) { TableTicker.setValueAt(settings.getTickers().get(i).getName(), i, 0); } update = 0; } } @Override public void updateVariables() { Settings settings = Controller.getSettings(); validate(); repaint(); timer.setDelay(settings.getVaribable(DDBB.RATIO_REFRESCO)); } @Override public void reomveTicker(int index) { synchronized (updateLock) { // Add in Tickers Table update = 2; DefaultTableModel model = (DefaultTableModel) TableTicker.getModel(); model.removeRow(index); // Remove row in Week Tables // Table Week 1 DefaultTableModel model1 = (DefaultTableModel) TableWeek1.getModel(); // Table Week 2 DefaultTableModel model2 = (DefaultTableModel) TableWeek2.getModel(); // Table Week 3 DefaultTableModel model3 = (DefaultTableModel) TableWeek3.getModel(); // Table Week 1 model1.removeRow(index); // Table Week 2 model2.removeRow(index); // Table Week 3 model3.removeRow(index); num_positions = Controller.getSettings().getTickers().size(); update = 0; } } }; Controller.setup(listener);/* = new Controller();*/ Settings settings = Controller.getSettings(); num_positions = Controller.getSettings().getTickers().size(); loadTableTickers(); loadTableWeek(TableWeek1, WEEK1); loadTableWeek(TableWeek2, WEEK2); loadTableWeek(TableWeek3, WEEK3); String cad = settings.getVaribable(DDBB.RANGO_1) > 1 ? "weeks" : "week"; cad = settings.getVaribable(DDBB.RANGO_2) > 1 ? "weeks" : "week"; cad = settings.getVaribable(DDBB.RANGO_3) > 1 ? "weeks" : "week"; TableTicker.setCellSelectionEnabled(false); TableWeek1.setCellSelectionEnabled(false); TableWeek2.setCellSelectionEnabled(false); TableWeek3.setCellSelectionEnabled(false); /*validate(); repaint();*/ settingsGUI = new SettingsGUI(listener); features = new Features(); features.setBackground(java.awt.Color.BLACK); }
From source file:captureplugin.CapturePlugin.java
/** * Check the programs after data update. *//*from ww w. ja v a 2s .com*/ public void handleTvDataUpdateFinished() { mNeedsUpdate = true; if (mAllowedToShowDialog) { mNeedsUpdate = false; DeviceIf[] devices = mConfig.getDeviceArray(); final DefaultTableModel model = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { return false; } }; model.setColumnCount(5); model.setColumnIdentifiers(new String[] { mLocalizer.msg("device", "Device"), Localizer.getLocalization(Localizer.I18N_CHANNEL), mLocalizer.msg("date", "Date"), ProgramFieldType.START_TIME_TYPE.getLocalizedName(), ProgramFieldType.TITLE_TYPE.getLocalizedName() }); JTable table = new JTable(model); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable renderTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(renderTable, value, isSelected, hasFocus, row, column); if (value instanceof DeviceIf) { if (((DeviceIf) value).getDeleteRemovedProgramsAutomatically() && !isSelected) { c.setForeground(Color.red); } } return c; } }); int[] columnWidth = new int[5]; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = UiUtilities.getStringWidth(table.getFont(), model.getColumnName(i)) + 10; } for (DeviceIf device : devices) { Program[] deleted = device.checkProgramsAfterDataUpdateAndGetDeleted(); if (deleted != null && deleted.length > 0) { for (Program p : deleted) { if (device.getDeleteRemovedProgramsAutomatically() && !p.isExpired() && !p.isOnAir()) { device.remove(UiUtilities.getLastModalChildOf(getParentFrame()), p); } else { device.removeProgramWithoutExecution(p); } if (!p.isExpired()) { Object[] o = new Object[] { device, p.getChannel().getName(), p.getDateString(), p.getTimeString(), p.getTitle() }; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = Math.max(columnWidth[i], UiUtilities.getStringWidth(table.getFont(), o[i].toString()) + 10); } model.addRow(o); } } } device.getProgramList(); } if (model.getRowCount() > 0) { int sum = 0; for (int i = 0; i < columnWidth.length; i++) { table.getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]); if (i < columnWidth.length - 1) { table.getColumnModel().getColumn(i).setMaxWidth(columnWidth[i]); } sum += columnWidth[i]; } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(450, 250)); if (sum > 500) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.getViewport().setPreferredSize( new Dimension(sum, scrollPane.getViewport().getPreferredSize().height)); } JButton export = new JButton(mLocalizer.msg("exportList", "Export list")); export.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileFilter(new FileFilter() { public boolean accept(File f) { return f.isDirectory() || f.toString().toLowerCase().endsWith(".txt"); } public String getDescription() { return "*.txt"; } }); chooser.setSelectedFile(new File("RemovedPrograms.txt")); if (chooser.showSaveDialog( UiUtilities.getLastModalChildOf(getParentFrame())) == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { String file = chooser.getSelectedFile().getAbsolutePath(); if (!file.toLowerCase().endsWith(".txt") && file.indexOf('.') == -1) { file = file + ".txt"; } if (file.indexOf('.') != -1) { try { RandomAccessFile write = new RandomAccessFile(file, "rw"); write.setLength(0); String eolStyle = File.separator.equals("/") ? "\n" : "\r\n"; for (int i = 0; i < model.getRowCount(); i++) { StringBuilder line = new StringBuilder(); for (int j = 0; j < model.getColumnCount(); j++) { line.append(model.getValueAt(i, j)).append(' '); } line.append(eolStyle); write.writeBytes(line.toString()); } write.close(); } catch (Exception ee) { } } } } } }); Object[] message = { mLocalizer.msg("deletedText", "The data was changed and the following programs were deleted:"), scrollPane, export }; JOptionPane pane = new JOptionPane(); pane.setMessage(message); pane.setMessageType(JOptionPane.PLAIN_MESSAGE); final JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(getParentFrame()), mLocalizer.msg("CapturePlugin", "CapturePlugin") + " - " + mLocalizer.msg("deletedTitle", "Deleted programs")); d.setResizable(true); d.setModal(false); SwingUtilities.invokeLater(new Runnable() { public void run() { d.setVisible(true); } }); } } }
From source file:jp.massbank.spectrumsearch.SearchPage.java
private void fillGuiDbTableData(List<GuiDbTableRow> rows) { DefaultTableModel dataModel = (DefaultTableModel) querySorter.getTableModel(); dataModel.setRowCount(0);/*from w ww . j a va2 s . c o m*/ Collections.sort(rows); if (rows != null && rows.size() > 0) { for (GuiDbTableRow row : rows) { dataModel.addRow(new String[] { row.getRecordId(), row.getRecordTitle(), row.getContributor(), row.getIndex() }); } } }
From source file:jp.massbank.spectrumsearch.SearchPage.java
private void fillGuiResultTableData(List<GuiResultTableRow> rows) { DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel(); dataModel.setRowCount(0);// w w w.j a v a 2 s . com Collections.sort(rows); if (rows != null && rows.size() > 0) { for (GuiResultTableRow row : rows) { dataModel.addRow(new Object[] { row.getRecordTitle(), row.getScore(), row.getHit(), row.getRecordId(), row.getIonMode(), row.getContributor(), row.getIndex() }); } } }
From source file:UserInterface.GarbageCollectorRole.GarbageCollectorWorkAreaJPanel.java
private void jRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRefreshActionPerformed DefaultTableModel model = (DefaultTableModel) jGarbageCollector.getModel(); model.setRowCount(0);/*from ww w . j a v a 2s . co m*/ for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { Object[] row = new Object[17]; row[0] = request; String area = ((GarbageCollectorWorkRequest) request).getArea(); row[1] = area; String metal = ((GarbageCollectorWorkRequest) request).getMetalGarbageStatus(); row[2] = metal; row[3] = ((GarbageCollectorWorkRequest) request).getBiodegradableStatus(); row[4] = ((GarbageCollectorWorkRequest) request).getPlasticStatus(); row[5] = ((GarbageCollectorWorkRequest) request).getStatus(); row[6] = ((GarbageCollectorWorkRequest) request).getSender(); row[7] = ((GarbageCollectorWorkRequest) request).getCollectedMetal(); row[8] = ((GarbageCollectorWorkRequest) request).getCollectedPlastic(); row[9] = ((GarbageCollectorWorkRequest) request).getCollectedDegradable(); row[10] = ((GarbageCollectorWorkRequest) request).getSegregatedMetal(); row[11] = ((GarbageCollectorWorkRequest) request).getSegregatedPlastic(); row[12] = ((GarbageCollectorWorkRequest) request).getSegregatedDegradable(); row[13] = ((GarbageCollectorWorkRequest) request).getSentToMD(); row[14] = ((GarbageCollectorWorkRequest) request).getSentToPD(); row[15] = ((GarbageCollectorWorkRequest) request).getSentToBD(); row[16] = ((GarbageCollectorWorkRequest) request).getType(); model.addRow(row); } jTypeOfGarbage.setEnabled(true); jRefresh.setEnabled(false); jButton1.setEnabled(true); jButton2.setEnabled(true); }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
private void addMetaDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addMetaDataButtonActionPerformed DefaultTableModel model = ((DefaultTableModel) metaDataTable.getModel()); int row = model.getRowCount(); model.addRow(new Object[] { "", MetaDataColumnType.STRING, "" }); metaDataTable.setRowSelectionInterval(row, row); revertMetaDataButton.setEnabled(true); parent.setSaveEnabled(true);//w w w .j a va 2 s . c om }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
private void updateTagTable() { DefaultTableModel model = (DefaultTableModel) tagTable.getModel(); model.setRowCount(0);/*from ww w. j a v a 2 s. com*/ for (String tag : currentChannel.getProperties().getTags()) { model.addRow(new Object[] { tag }); } }