List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel
public DefaultTableModel(Object[][] data, Object[] columnNames)
DefaultTableModel
and initializes the table by passing data
and columnNames
to the setDataVector
method. From source file:Vista.VentasCiudad.java
private void jButton_executeGeneralVC1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_executeGeneralVC1ActionPerformed //String[] respuesta = client.consultaGeneralCiudad("0;" + jTextField_Ciudad.getText(), "").split(";"); String[] respuesta = client.consultaGeneralCiudad("0;0", jTextField_Ciudad.getText().trim()).split(";"); String[] nombres = { "Id", "Ciudad", "Total Ventas" }; DefaultTableModel dtm = new DefaultTableModel(nombres, respuesta.length); dtm = (DefaultTableModel) this.jTable_ConsultaEspecifica.getModel(); this.jTable_ConsultaGeneral.removeAll(); for (String s : respuesta) { String[] columnasT = s.split("\\t"); dtm.addRow(new Object[] { columnasT[0], columnasT[1], columnasT[2] }); }// w ww. j a v a 2s.co m }
From source file:musiccrawler.App.java
private void btnQueryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQueryActionPerformed if (Utils.isNull(rdgQuery.getSelection())) { JOptionPane.showMessageDialog(this, "Plz, check option before perform action query"); return;//from www . j a v a 2 s. c om } DefaultTableModel defaultTableModel = new DefaultTableModel(COLUMN_NAMES, 0); boolean isQueryGetAll = rdbQueryAll.isSelected(); if (isQueryGetAll) { getAllMusic(defaultTableModel); } else { getMusicByOption(dataCallBack, defaultTableModel); } }
From source file:view.App.java
public void addData(final List<SpreadObject> spreadList) { Object rows[][] = new Object[spreadList.size()][4]; for (int j = 0; j < spreadList.size(); j++) { SpreadObject currPair = spreadList.get(j); int lastIndexBase = currPair.getBaseStock().getData().size(); int lastIndexSec = currPair.getSecondStock().getData().size(); DailyData firstVal = currPair.getBaseStock().getData().get(lastIndexBase - 1); DailyData secVal = currPair.getSecondStock().getData().get(lastIndexSec - 1); // int size = currPair.getData().size(); rows[j][0] = currPair.getBaseStock().getTicker(); rows[j][1] = firstVal.getAverVolatile().toPlainString(); rows[j][2] = currPair.getSecondStock().getTicker(); rows[j][3] = secVal.getAverVolatile().toPlainString(); }// w w w . j a va 2 s . co m DefaultTableModel model = new DefaultTableModel(rows, new String[] { "", "MA Value", "", "MA Value" }) { public boolean isCellEditable(int row, int column) { return false; }; void reset() { this.setColumnCount(0); } }; jTable1.setModel(model); jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent arg0) { int selectedRow = jTable1.getSelectedRow(); SpreadObject obj = spreadList.get(selectedRow); renderChart(obj); } }); }
From source file:Vista.CuentasCobrar.java
private void jButton_EjecuteCXCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_EjecuteCXCActionPerformed // TODO add your handling code here: String[] resp = client.consultarCuentas("0;0", Client.getCity()).split("\\n"); String[] nombres = { "Nombre", "Numero de Contacto", "Empresa", "Numero de facturas" }; DefaultTableModel dtm = new DefaultTableModel(nombres, resp.length); dtm = (DefaultTableModel) this.jTable_CuentasPorCobrar.getModel(); this.jTable_CuentasPorCobrar.removeAll(); for (String s : resp) { String[] columnasT = s.split("\\t"); dtm.addRow(new Object[] { columnasT[1], columnasT[2], columnasT[3], columnasT[4] }); }/*from w w w.j ava2 s .com*/ }
From source file:Vista.VentasCliente.java
private void jButton_executeGeneralVClActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_executeGeneralVClActionPerformed String[] nombres = { "Nombre", "Numero de Contacto", "Empresa", "Numero de facturas" }; String[] filasT = client.consultaGeneralCliente("0;0", "").split("\\n"); DefaultTableModel dtm = new DefaultTableModel(nombres, filasT.length); dtm = (DefaultTableModel) this.jTable_ConsultaGeneralCliente.getModel(); this.jTable_ConsultaGeneralCliente.removeAll(); for (String s : filasT) { String[] columnasT = s.split("\\t"); dtm.addRow(new Object[] { columnasT[1], columnasT[2], columnasT[3], columnasT[4] }); }//from ww w .j a va2 s . c o m }
From source file:Vista.VentasCiudad.java
private void jTable_ConsultaGeneralMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable_ConsultaGeneralMouseClicked this.jTable_ConsultaSucursal.repaint(); String[] nombres = { "Id", "Sucursal", "Total Ventas" }; String[] filasT = client.consultarSucursal("1;" + jTable_ConsultaGeneral.getModel() .getValueAt(jTable_ConsultaGeneral.getSelectionModel().getAnchorSelectionIndex(), 0).toString(), "") .split("\\n"); DefaultTableModel dtm = new DefaultTableModel(nombres, filasT.length); dtm = (DefaultTableModel) this.jTable_ConsultaSucursal.getModel(); for (String s : filasT) { String[] columnasT = s.split("\\t"); dtm.addRow(new Object[] { columnasT[0], columnasT[1], columnasT[2] }); }/* w w w. ja va 2s . co m*/ }
From source file:coolmap.application.widget.impl.WidgetUserGroup.java
private void updateTable() { ArrayList<String> keys = new ArrayList<>(nodeGroups.keySet()); Collections.sort(keys);//from w w w.j a va 2 s .co m Object[][] data = new Object[keys.size()][4]; for (int i = 0; i < keys.size(); i++) { String key = keys.get(i); List<VNode> nodes = nodeGroups.get(key); data[i][0] = key; data[i][1] = " "; data[i][2] = nodes.size(); data[i][3] = nodes.toString(); } final DefaultTableModel model = new DefaultTableModel(data, colLabels) { @Override public boolean isCellEditable(int row, int column) { return false; } }; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { table.setModel(model); } }); }
From source file:view.caja.Despacho.java
public JScrollPane getTablaProductos() { Object[][] datitos = {};/*from ww w . j av a 2 s .c o m*/ String[] columnas_Name = { "#", "Producto", "Precio", "Codigo", "Cantidad", "IDprod" }; TableModel jTable1Model = new DefaultTableModel(datitos, columnas_Name) { public boolean isCellEditable(int row, int column) { return false; } }; tbCarrito = new JTable(); tbCarrito.setModel(jTable1Model); tbCarrito.getTableHeader().setReorderingAllowed(false); tbCarrito.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tbCarrito.setPreferredScrollableViewportSize(new Dimension(400, 350)); tbCarrito.setPreferredSize(new java.awt.Dimension(351, 283)); tbCarrito.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); tbCarrito.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (tbCarrito.getRowCount() != 0) { fila = tbCarrito.getSelectedRow(); columna = tbCarrito.getSelectedColumn(); btQuitar.setEnabled(true); } } }); scrollProds = new JScrollPane(tbCarrito); return scrollProds; }
From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java
private JPanel createStatPanel(Stx stx, final Mask mask) { final Histogram histogram = stx.getHistogram(); XIntervalSeries histogramSeries = new XIntervalSeries("Histogram"); int[] bins = histogram.getBins(0); for (int j = 0; j < bins.length; j++) { histogramSeries.add(histogram.getBinLowValue(0, j), histogram.getBinLowValue(0, j), j < bins.length - 1 ? histogram.getBinLowValue(0, j + 1) : histogram.getHighValue(0), bins[j]); }/*from w w w. j av a 2 s. co m*/ ChartPanel histogramPanel = createChartPanel(histogramSeries, "Value", "#Pixels", new Color(0, 0, 127)); XIntervalSeries percentileSeries = new XIntervalSeries("Percentile"); percentileSeries.add(0, 0, 1, histogram.getLowValue(0)); for (int j = 1; j < 99; j++) { percentileSeries.add(j, j, j + 1, histogram.getPTileThreshold(j / 100.0)[0]); } percentileSeries.add(99, 99, 100, histogram.getHighValue(0)); ChartPanel percentilePanel = createChartPanel(percentileSeries, "Percentile (%)", "Value Threshold", new Color(127, 0, 0)); Object[][] tableData = new Object[][] { new Object[] { "#Pixels total:", histogram.getTotals()[0] }, new Object[] { "Minimum:", stx.getMinimum() }, new Object[] { "Maximum:", stx.getMaximum() }, new Object[] { "Mean:", stx.getMean() }, new Object[] { "Sigma:", stx.getStandardDeviation() }, new Object[] { "Median:", stx.getMedian() }, new Object[] { "Coef Variation:", stx.getCoefficientOfVariation() }, new Object[] { "ENL:", stx.getEquivalentNumberOfLooks() }, new Object[] { "P75 threshold:", histogram.getPTileThreshold(0.75)[0] }, new Object[] { "P80 threshold:", histogram.getPTileThreshold(0.80)[0] }, new Object[] { "P85 threshold:", histogram.getPTileThreshold(0.85)[0] }, new Object[] { "P90 threshold:", histogram.getPTileThreshold(0.90)[0] }, new Object[] { "Max error:", getBinSize(histogram) }, }; JPanel plotContainerPanel = new JPanel(new GridLayout(1, 2)); plotContainerPanel.add(histogramPanel); plotContainerPanel.add(percentilePanel); TableModel tableModel = new DefaultTableModel(tableData, new String[] { "Name", "Value" }) { @Override public Class<?> getColumnClass(int columnIndex) { return columnIndex == 0 ? String.class : Number.class; } @Override public boolean isCellEditable(int row, int column) { return false; } }; final JTable table = new JTable(tableModel); table.setDefaultRenderer(Number.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Component label = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof Float || value instanceof Double) { setHorizontalTextPosition(RIGHT); setText(getFormattedValue((Number) value)); } return label; } private String getFormattedValue(Number value) { if (value.doubleValue() < 0.001 && value.doubleValue() > -0.001 && value.doubleValue() != 0.0) { return new DecimalFormat("0.####E0").format(value.doubleValue()); } return String.format("%.4f", value.doubleValue()); } }); table.addMouseListener(popupHandler); JPanel textContainerPanel = new JPanel(new BorderLayout(2, 2)); textContainerPanel.setBackground(Color.WHITE); textContainerPanel.add(table, BorderLayout.CENTER); JPanel statPanel = new JPanel(new BorderLayout(4, 4)); statPanel.setBorder(new EmptyBorder(10, 2, 10, 2)); statPanel.setBackground(Color.WHITE); statPanel.add(new JLabel(getSubPanelTitle(mask)), BorderLayout.NORTH); statPanel.add(textContainerPanel, BorderLayout.WEST); statPanel.add(plotContainerPanel, BorderLayout.CENTER); return statPanel; }
From source file:Vista.VentasCiudad.java
private void jButton_executeGeneralVCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_executeGeneralVCActionPerformed String[] nombres = { "Id", "Ciudad", "Total Ventas" }; String[] filasT = client.consultaGeneralCiudad("0;0", "").split("\\n"); DefaultTableModel dtm = new DefaultTableModel(nombres, filasT.length); dtm = (DefaultTableModel) this.jTable_ConsultaGeneral.getModel(); this.jTable_ConsultaGeneral.removeAll(); for (String s : filasT) { String[] columnasT = s.split("\\t"); dtm.addRow(new Object[] { columnasT[0], columnasT[1], columnasT[2] }); }//from w w w.j a va 2 s . c o m }