List of usage examples for javax.swing.table DefaultTableModel getValueAt
public Object getValueAt(int row, int column)
row
and column
. From source file:at.nullpointer.trayrss.gui.tablemodel.TableModelFactory.java
public static Set<Feed> retrieveFeeds(TableModel model) { DefaultTableModel dtm = (DefaultTableModel) model; int rowCount = dtm.getRowCount(); FeedRepository feedRepository = ReferenceCollection.getInstance().getContext().getBean("feedRepository", FeedRepository.class); Set<Feed> result = new HashSet<Feed>(); for (int row = 0; row < rowCount; row++) { Feed erg = null;//www . j ava 2 s . c om String valueAt = (String) dtm.getValueAt(row, TableColumnUtil.FEED_URL); if (StringUtils.isNotEmpty(valueAt)) { erg = feedRepository.retrieveFeed(valueAt); } if (erg == null) { erg = new Feed(); } erg.setName((String) dtm.getValueAt(row, TableColumnUtil.FEED_NAME)); erg.setUrl((String) dtm.getValueAt(row, TableColumnUtil.FEED_URL)); erg.setIntervall((Long) dtm.getValueAt(row, TableColumnUtil.INTERVALL)); erg.setMonitored((Boolean) dtm.getValueAt(row, TableColumnUtil.MONITORED)); Date noAction = new Date(0); erg.setLastAction(noAction); result.add(erg); } return result; }
From source file:de.main.sessioncreator.ReportingHelper.java
public String getAllSessionCount(DefaultTableModel model) { int rows = model.getRowCount(); int counter = 0; int i = 0;/*from w w w. j a v a2s. co m*/ while (i < rows) { counter += Integer.valueOf(model.getValueAt(i, 1).toString()); i++; } return String.valueOf(counter); }
From source file:UserInterface.Supplier.SalesOverviewJPanel.java
private void findTopProduct() { int max = 0;/* w w w.ja v a 2 s .c om*/ int current = 0; String currentPName = "null"; ArrayList<String> currentPList = new ArrayList<>(); currentPList.add("null"); DefaultTableModel dtm = (DefaultTableModel) performanceJTable.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { current = (int) dtm.getValueAt(i, 1); if (max < current) { max = current; currentPName = (String) dtm.getValueAt(i, 0); currentPList.clear(); currentPList.add(currentPName); } else if (max == current) { currentPName = (String) dtm.getValueAt(i, 0); currentPList.add(currentPName); } } topSellingJLabel.setText(currentPList.toString()); }
From source file:UserInterface.AdminWorkArea.InventoryUsageJPanel.java
public void findLeastUsedDevices() { int min = 0;//from w w w . java 2 s.c o m int current = 0; String currentPName = "null"; ArrayList<String> currentPList = new ArrayList<>(); currentPList.add("null"); DefaultTableModel dtm = (DefaultTableModel) deviceUsageJTable.getModel(); min = (int) dtm.getValueAt(0, 1); for (int i = 0; i < dtm.getRowCount(); i++) { current = (int) dtm.getValueAt(i, 1); if (min > current) { min = current; IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.clear(); currentPList.add(currentPName); } else if (min == current) { IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.add(currentPName); } } leastUsedLabel.setText(currentPList.toString()); }
From source file:com.mirth.connect.client.ui.ChannelTagDialog.java
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed String tag = StringUtils.trim((String) tagComboBox.getSelectedItem()); if (tag == null || tag.isEmpty()) { parent.alertError(parent, "Please enter a tag"); } else {//w ww. ja v a 2 s . c o m DefaultTableModel model = (DefaultTableModel) tagTable.getModel(); int rowCount = model.getRowCount(); for (int i = 0; i < rowCount; i++) { if (model.getValueAt(i, 0).equals(tag)) { parent.alertError(parent, "\"" + tag + "\" is already assigned to this channel"); return; } } model.addRow(new Object[] { tag }); tagTable.setRowSelectionInterval(rowCount, rowCount); dispose(); } }
From source file:com.mirth.connect.client.ui.ChannelTagDialog.java
@Override public void setVisible(boolean visible) { if (visible) { Dimension dlgSize = getPreferredSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { setLocationRelativeTo(null); } else {/* w w w . ja va 2 s .c om*/ setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } Set<String> availableTags = new LinkedHashSet<String>(parent.getChannelTagInfo(false).getTags()); DefaultTableModel model = (DefaultTableModel) tagTable.getModel(); int rowCount = model.getRowCount(); for (int i = 0; i < rowCount; i++) { availableTags.remove(model.getValueAt(i, 0)); } tagComboBox.setModel(new DefaultComboBoxModel(availableTags.toArray())); if (availableTags.size() > 0) { tagComboBox.setSelectedIndex(0); } tagComboBox.requestFocusInWindow(); } super.setVisible(visible); }
From source file:gtu._work.ui.JSFMakerUI_attrDialog.java
public String getAttribute() { DefaultTableModel model = (DefaultTableModel) attrTable.getModel(); Attribute attr = null;//from ww w .jav a 2s . c om boolean enable = false; StringBuilder sb = new StringBuilder(); for (int ii = 0; ii < model.getRowCount(); ii++) { attr = (Attribute) model.getValueAt(ii, Function.VALUE.col); enable = (Boolean) model.getValueAt(ii, Function.ENABLE.col); if (StringUtils.isNotEmpty(attr.value) && enable) { sb.append(String.format(" %s=\"%s\"", attr.name, attr.value)); } } return sb.toString(); }
From source file:graph.plotter.PieMenu.java
/** * This method works for showing clicked data in textFields * @param evt /*from w w w . ja va 2 s . co m*/ */ private void TableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TableMouseClicked DefaultTableModel model = (DefaultTableModel) Table.getModel(); jTextField1.setText(model.getValueAt(Table.getSelectedRow(), 0).toString()); jTextField2.setText(model.getValueAt(Table.getSelectedRow(), 1).toString()); }
From source file:com.willwinder.universalgcodesender.uielements.panels.ControllerProcessorSettingsPanel.java
@Override public void save() { // In case there are in-progress changes. TableCellEditor editor = customRemoverTable.getCellEditor(); if (editor != null) { editor.stopCellEditing();//from w w w . j a v a 2 s . c o m } ConfigTuple ct = configFiles.get(controllerConfigs.getSelectedItem()); ct.loader.getProcessorConfigs().Custom.clear(); // Roll up the pattern processors. DefaultTableModel model = (DefaultTableModel) this.customRemoverTable.getModel(); for (int i = 0; i < customRemoverTable.getRowCount(); i++) { JsonObject args = new JsonObject(); String pattern = model.getValueAt(i, 1).toString(); if (!StringUtils.isEmpty(pattern)) { args.addProperty("pattern", pattern); ProcessorConfig pc = new ProcessorConfig("PatternRemover", (Boolean) model.getValueAt(i, 0), true, args); ct.loader.getProcessorConfigs().Custom.add(pc); } } try { FirmwareUtils.save(ct.file, ct.loader); } catch (IOException ex) { GUIHelpers.displayErrorDialog("Problem saving controller config: " + ex.getMessage()); logger.log(Level.SEVERE, null, ex); } }
From source file:UserInterface.AdminWorkArea.InventoryUsageJPanel.java
public void findTopDevice() { int max = 0;/*from w w w .jav a 2 s. co m*/ int current = 0; String currentPName = "null"; ArrayList<String> currentPList = new ArrayList<>(); currentPList.add("null"); DefaultTableModel dtm = (DefaultTableModel) deviceUsageJTable.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { current = (int) dtm.getValueAt(i, 1); if (max < current) { max = current; IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.clear(); currentPList.add(currentPName); } else if (max == current) { IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.add(currentPName); } } mostUsedLabel.setText(currentPList.toString()); }