List of usage examples for javax.swing.table DefaultTableModel removeRow
public void removeRow(int row)
row
from the model. From source file:gdt.jgui.tool.JEntityEditor.java
private void replaceTable(Core[] ca) { try {/*from ww w. j a v a 2s.co m*/ JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel model = (DefaultTableModel) table.getModel(); while (model.getRowCount() > 0) model.removeRow(0); int cnt = ca.length; if (cnt < 1) return; for (int i = 0; i < cnt; i++) model.addRow(new String[] { ca[i].type, ca[i].name, ca[i].value }); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:frames.MainGUI.java
private String removeItemFromFeeTable(int i) { DefaultTableModel model = (DefaultTableModel) this.jTable2.getModel(); String name = (String) model.getValueAt(i, 0); model.removeRow(i); this.resetButtons(); return name;/* w w w.j a v a 2 s . co m*/ }
From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java
private void clearProperties() { scheduleTypeComboBox.setSelectedItem(PollingType.INTERVAL.getDisplayName()); noStartPollRadioButton.setSelected(true); SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm aa"); pollingTimePicker.setDate(dateFormat.format(Calendar.getInstance().getTime())); DefaultTableModel model = (DefaultTableModel) cronJobsTable.getModel(); for (int index = model.getRowCount() - 1; index >= 0; index--) { model.removeRow(index); }/*from w w w . j a v a 2 s . c o m*/ Vector<String> row = new Vector<String>(); if (channelContext) { pollingFrequencyTypeComboBox.setSelectedItem(POLLING_FREQUENCY_SECONDS); pollingFrequencyField.setText("5"); row.add(defaultCronJob); row.add("Run every 5 seconds."); } else { pollingFrequencyTypeComboBox.setSelectedItem(POLLING_FREQUENCY_HOURS); pollingFrequencyField.setText("1"); row.add("0 0 */1 * * ?"); row.add("Run hourly."); } model.addRow(row); cachedAdvancedConnectorProperties = new PollConnectorPropertiesAdvanced(); }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
private void replaceTable(Core[] ca) { try {//from w w w.ja va 2 s . com table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel model = (DefaultTableModel) table.getModel(); while (model.getRowCount() > 0) model.removeRow(0); int cnt = ca.length; if (cnt < 1) return; for (int i = 0; i < cnt; i++) model.addRow(new String[] { ca[i].name, ca[i].value }); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:userinterface.Citizen.CitizenWorkAreaJPanel.java
public void populateTable() { DefaultTableModel dtm = (DefaultTableModel) vitalSigntable.getModel(); int rowCount = vitalSigntable.getRowCount(); for (int i = rowCount - 1; i >= 0; i--) { dtm.removeRow(i); }/*from w w w. j a v a 2 s .c o m*/ for (VitalSign vs : account.getCitizen().getHealthReport().getVitalSigns()) { Object row[] = new Object[2]; row[0] = vs; if (vs.isVitalSignsNormal()) { row[1] = "Normal"; } else { row[1] = "Abnormal"; } dtm.addRow(row); } }
From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java
private void initComponents() { scheduleTypeLabel = new JLabel("Schedule Type:"); scheduleTypeComboBox = new MirthComboBox(); // @formatter:off scheduleTypeComboBox/*from w ww. j a va2s . c o m*/ .setToolTipText("<html>This connector polls to determine when new messages have arrived.<br>" + "Select \"Interval\" to poll each n units of time.<br>" + "Select \"Time\" to poll once a day at the specified time.<br>" + "Select \"Cron\" to poll at the specified cron expression(s).</html>"); // @formatter:on scheduleTypeComboBox.addItem(PollingType.INTERVAL.getDisplayName()); scheduleTypeComboBox.addItem(PollingType.TIME.getDisplayName()); scheduleTypeComboBox.addItem(PollingType.CRON.getDisplayName()); scheduleTypeActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { scheduleTypeActionPerformed(); updateNextFireTime(); } }; nextPollLabel = new JLabel("Next poll at: "); yesStartPollRadioButton = new MirthRadioButton("Yes"); yesStartPollRadioButton.setToolTipText( "<html>Select Yes to immediately poll once on start.<br/>All subsequent polling will follow the specified schedule.</html>"); yesStartPollRadioButton.setBackground(UIConstants.BACKGROUND_COLOR); yesStartPollRadioButton.setFocusable(false); noStartPollRadioButton = new MirthRadioButton("No"); noStartPollRadioButton.setToolTipText( "<html>Select Yes to immediately poll once on start.<br/>All subsequent polling will follow the specified schedule.</html>"); noStartPollRadioButton.setBackground(UIConstants.BACKGROUND_COLOR); noStartPollRadioButton.setSelected(true); noStartPollRadioButton.setFocusable(false); pollOnStartButtonGroup = new ButtonGroup(); pollOnStartButtonGroup.add(yesStartPollRadioButton); pollOnStartButtonGroup.add(noStartPollRadioButton); pollingTimePicker = new MirthTimePicker(); pollingTimePicker.setToolTipText("The time of day to poll."); pollingTimePicker.setVisible(false); JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) pollingTimePicker.getEditor(); JTextField textField = editor.getTextField(); textField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent event) { updateNextFireTime(); } public void removeUpdate(DocumentEvent e) { } public void changedUpdate(DocumentEvent e) { } }); pollingFrequencySettingsPanel = new JPanel(); pollingFrequencySettingsPanel.setBackground(UIConstants.BACKGROUND_COLOR); pollingFrequencySettingsPanel.setVisible(true); pollingFrequencyField = new MirthTextField(); pollingFrequencyField.setToolTipText( "<html>The specified repeating time interval.<br/>Units must be less than 24 hours of time<br/>when converted to milliseconds.</html>"); pollingFrequencyField.setSize(new Dimension(200, 20)); pollingFrequencyField.setDocument(new MirthFieldConstraints(0, false, false, true)); pollingFrequencyField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { updateNextFireTime(); } @Override public void removeUpdate(DocumentEvent e) { updateNextFireTime(); } @Override public void changedUpdate(DocumentEvent e) { } }); pollingFrequencyTypeComboBox = new MirthComboBox(); pollingFrequencyTypeComboBox.setToolTipText("The interval's unit of time."); pollingFrequencyTypeComboBox.addItem(POLLING_FREQUENCY_MILLISECONDS); pollingFrequencyTypeComboBox.addItem(POLLING_FREQUENCY_SECONDS); pollingFrequencyTypeComboBox.addItem(POLLING_FREQUENCY_MINUTES); pollingFrequencyTypeComboBox.addItem(POLLING_FREQUENCY_HOURS); pollingFrequencyTypeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateNextFireTime(); } }); pollingCronSettingsPanel = new JPanel(); pollingCronSettingsPanel.setBackground(UIConstants.BACKGROUND_COLOR); pollingCronSettingsPanel.setVisible(false); cronJobsTable = new MirthTable(); Object[][] tableData = new Object[0][1]; cronJobsTable.setModel(new RefreshTableModel(tableData, new String[] { "Expression", "Description" })); cronJobsTable.setOpaque(true); cronJobsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); cronJobsTable.getTableHeader().setReorderingAllowed(false); cronJobsTable.setSortable(false); cronJobsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cronJobsTable.getColumnModel().getColumn(0).setResizable(false); cronJobsTable.getColumnModel().getColumn(0).setCellEditor(new CronTableCellEditor(true)); cronJobsTable.getColumnModel().getColumn(1).setResizable(false); cronJobsTable.getColumnModel().getColumn(1).setCellEditor(new CronTableCellEditor(true)); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); cronJobsTable.setHighlighters(highlighter); } HighlightPredicate errorHighlighterPredicate = new HighlightPredicate() { public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { if (adapter.column == cronJobsTable.getColumnViewIndex("Expression")) { String cronExpression = (String) cronJobsTable.getValueAt(adapter.row, adapter.column); if (invalidExpressions.contains(cronExpression)) { return true; } } return false; } }; errorHighlighter = new ColorHighlighter(errorHighlighterPredicate, Color.PINK, Color.BLACK, Color.PINK, Color.BLACK); //@formatter:off String tooltip = "<html><head><style>td {text-align:center;}</style></head>" + "Cron expressions must be in Quartz format with at least 6 fields.<br/>" + "<br/>Format:" + "<table>" + "<tr><td>Field</td><td>Required</td><td>Values</td><td>Special Characters</td></tr>" + "<tr><td>Seconds</td><td>YES</td><td>0-59</td><td>, - * /</td></tr>" + "<tr><td>Minutes</td><td>YES</td><td>0-59</td><td>, - * /</td></tr>" + "<tr><td>Hours</td><td>YES</td><td>0-23</td><td>, - * /</td></tr>" + "<tr><td>Day of Month</td><td>YES</td><td>1-31</td><td>, - * ? / L W</td></tr>" + "<tr><td>Month</td><td>YES</td><td>1-12 or JAN-DEC</td><td>, - * /</td></tr>" + "<tr><td>Day of Week</td><td>YES</td><td>1-7 or SUN-SAT</td><td>, - * ? / L #</td></tr>" + "<tr><td>Year</td><td>NO</td><td>empty, 1970-2099</td><td>, - * /</td></tr>" + "</table>" + "<br/>Special Characters:" + "<br/>   <b>*</b> : all values" + "<br/>   <b>?</b> : no specific value" + "<br/>   <b>-</b> : used to specify ranges" + "<br/>   <b>,</b> : used to specify list of values" + "<br/>   <b>/</b> : used to specify increments" + "<br/>   <b>L</b> : used to specify the last of" + "<br/>   <b>W</b> : used to specify the nearest weekday" + "<br/>   <b>#</b> : used to specify the nth day of the month" + "<br/><br/>Example: 0 */5 8-17 * * ? means to fire every 5 minutes starting at 8am<br/>and ending at 5pm everyday" + "<br/><br/><b>Note:</b> Support for specifying both a day-of-week and day-of-month<br/>is not yet supported. A ? must be used in one of these fields.</html>"; //@formatter:on cronJobsTable.setToolTipText(tooltip); cronJobsTable.getTableHeader().setToolTipText(tooltip); cronScrollPane = new JScrollPane(); cronScrollPane.getViewport().add(cronJobsTable); addJobButton = new JButton("Add"); addJobButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ((DefaultTableModel) cronJobsTable.getModel()).addRow(new Vector<String>()); int rowSelectionNumber = cronJobsTable.getRowCount() - 1; cronJobsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); Boolean enabled = deleteJobButton.isEnabled(); if (!enabled) { deleteJobButton.setEnabled(true); } updateNextFireTime(); } }); deleteJobButton = new JButton("Delete"); deleteJobButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { int rowSelectionNumber = cronJobsTable.getSelectedRow(); if (rowSelectionNumber > -1) { DefaultTableModel model = (DefaultTableModel) cronJobsTable.getModel(); model.removeRow(rowSelectionNumber); rowSelectionNumber--; if (rowSelectionNumber > -1) { cronJobsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); } else if (cronJobsTable.getRowCount() > 0) { cronJobsTable.setRowSelectionInterval(0, 0); } if (cronJobsTable.getRowCount() == 0) { deleteJobButton.setEnabled(false); } } updateNextFireTime(); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); deleteJobButton.setEnabled(false); advancedSettingsButton = new JButton(new ImageIcon(Frame.class.getResource("images/wrench.png"))); advancedSettingsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { lastSelectedPollingType = StringUtils.isBlank(lastSelectedPollingType) ? "Interval" : lastSelectedPollingType; new AdvancedPollingSettingsDialog(lastSelectedPollingType, cachedAdvancedConnectorProperties, channelContext); updateNextFireTime(); } }); timeSettingsLabel = new JLabel("Interval:"); timeSettingsLabel.setBackground(UIConstants.BACKGROUND_COLOR); scheduleSettingsPanel = new JPanel(); scheduleSettingsPanel.setBackground(UIConstants.BACKGROUND_COLOR); if (!channelContext) { // @formatter:off scheduleTypeComboBox.setToolTipText("<html>Select the pruning schedule type.<br>" + "Select \"Interval\" to prune each n units of time.<br>" + "Select \"Time\" to prune once a day at the specified time.<br>" + "Select \"Cron\" to prune at the specified cron expression(s).</html>"); // @formatter:on pollingFrequencyField.setToolTipText( "<html>The specified repeating time interval.<br/>Units must be between 1 and 24 hours of time<br/>when converted to milliseconds.</html>"); } }
From source file:uk.ac.ox.cbrg.cpfp.uploadapp.UploadApplet.java
private void btnDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDelActionPerformed int selRows[] = fileTable.getSelectedRows(); DefaultTableModel fileModel = (DefaultTableModel) fileTable.getModel(); // Delete all selected files from the table AND file list int numRows = fileTable.getSelectedRows().length; for (int i = 0; i < numRows; i++) { int delRow = fileTable.getSelectedRow(); String fileName = (String) fileModel.getValueAt(delRow, 0); uploadFiles.remove(delRow);//from w ww .j a v a2 s . com fileModel.removeRow(delRow); } // if not files left disable upload if (uploadFiles.isEmpty()) { btnUpload.setEnabled(false); } }
From source file:com.net2plan.gui.GUINet2Plan.java
private void showKeyCombinations() { Component component = container.getComponent(0); if (!(component instanceof IGUIModule)) { ErrorHandling.showErrorDialog("No tool is active", "Unable to show key associations"); return;/*from ww w . j a v a2s.c o m*/ } final JDialog dialog = new JDialog(); dialog.setTitle("Key combinations"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Key combination", "Action"); DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); AdvancedJTable table = new AdvancedJTable(model); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); IGUIModule module = (IGUIModule) component; Map<String, KeyStroke> keyCombinations = module.getKeyCombinations(); if (!keyCombinations.isEmpty()) { model.removeRow(0); for (Entry<String, KeyStroke> keyCombination : keyCombinations.entrySet()) { String description = keyCombination.getKey(); KeyStroke keyStroke = keyCombination.getValue(); model.addRow(StringUtils.arrayOf(description, keyStroke.toString().replaceAll(" pressed ", " "))); } } dialog.setVisible(true); }
From source file:view.caja.Despacho.java
public void quitarFila() { if (tbCarrito.getRowCount() != 0) { if (fila >= 0) { contador--;/* w ww. ja v a 2 s .c om*/ DefaultTableModel defModel = (DefaultTableModel) tbCarrito.getModel(); //System.out.println(Double.parseDouble(tbCarrito.getValueAt(fila,2).toString())); //System.out.println(Integer.parseInt(tbCarrito.getValueAt(fila,4).toString())); double valProdSelected = Double.parseDouble(tbCarrito.getValueAt(fila, 2).toString()) * Integer.parseInt(tbCarrito.getValueAt(fila, 4).toString()); aCobrar = aCobrar - valProdSelected; jlblACobrarMostrar.setText(Double.toString(aCobrar)); jlblCantMostrar.setText(Integer.toString(contador)); defModel.removeRow(fila); fila = -1; for (int indexTable = tbCarrito.getRowCount() - 1; indexTable >= 0; indexTable--) { defModel.setValueAt(indexTable + 1, indexTable, 0); } System.out.println(aCobrar); btQuitar.setEnabled(false); if (tbCarrito.getRowCount() == 0) { btRemoveAll.setEnabled(false); } } } else { btQuitar.setEnabled(false); System.out.println("nada que quitar"); } }
From source file:main.java.edu.isistan.genCom.gui.Principal.java
/** * Elimina las filas de una tabla// ww w . j a va2 s.c om * * @param dtm * Modelo de la tabla */ private void limpiarModelo(DefaultTableModel dtm) { int j = dtm.getRowCount(); for (int i = j - 1; i >= 0; i--) { dtm.removeRow(i); } }