List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:app.RunApp.java
/** * Generates TableModel for IR intra class * /* www . ja v a 2 s . com*/ * @param jtable * @return */ private TableModel irIntraClassTableModel(JTable jtable) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("IR"); Object[] row = new Object[2]; String truncate; for (int i = 0; i < imbalancedLabels.length; i++) { truncate = Double.toString(imbalancedLabels[i].getIRIntraClass()); row[0] = imbalancedLabels[i].getName(); row[1] = MetricUtils.getValueFormatted(truncate, 3); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(80); tcm.getColumn(1).setPreferredWidth(50); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Generates TableModel for attributes// w w w . ja v a 2s .c o m * * @param jtable Table * @param dataset Multi-label dataset * @return Generated TableModel */ private TableModel attributesTableModel(JTable jtable, MultiLabelInstances dataset) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Attribute"); Object[] row = new Object[1]; Instances instances = dataset.getDataSet(); int numLabels = dataset.getNumLabels(); int numAttributes = instances.numAttributes() - numLabels; Attribute att; for (int i = 0; i < numAttributes; i++) { att = instances.attribute(i); if (att.isNumeric()) { row[0] = att.name(); tableModel.addRow(row); } } jtable.setModel(tableModel); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Generates TableModel for IR inter class * //ww w . j av a2 s .com * @param jtable * @return */ private TableModel irInterClassTableModel(JTable jtable) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("IR"); Object[] row = new Object[2]; String truncate; IRInterClass = MetricUtils.getIRInterClassValues(labelAppearances); int temp = IRInterClass.length - 1; for (int i = temp; i >= 0; i--) { truncate = Double.toString(IRInterClass[i]); row[0] = labelAppearances[i].getName(); row[1] = MetricUtils.getValueFormatted(truncate, 3); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(80); tcm.getColumn(1).setPreferredWidth(50); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Generate TableModel for label frequency * /*from ww w. ja v a 2 s . c om*/ * @param jtable Table * @param dataset Multi-label dataset * @return Generated TableModel */ private TableModel labelFrequencyTableModel(JTable jtable, MultiLabelInstances dataset) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("# Examples"); tableModel.addColumn("Frequency"); Object[] row = new Object[3]; ImbalancedFeature current; double freq; String truncate; for (int i = 0; i < dataset.getNumLabels(); i++) { current = labelAppearances[i]; row[0] = current.getName(); freq = current.getAppearances() * 1.0 / dataset.getNumInstances(); row[1] = current.getAppearances(); truncate = Double.toString(freq); row[2] = MetricUtils.truncateValue(truncate, 4); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(80); tcm.getColumn(1).setPreferredWidth(70); tcm.getColumn(2).setPreferredWidth(70); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Generates TableModel for frequency values * /*www .j ava 2 s . c om*/ * @param jtable Table * @param dataset Multi-label dataset * @return Generated TableModel */ private TableModel frequencyTableModel(JTable jtable, MultiLabelInstances dataset) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("# Examples"); tableModel.addColumn("Frequency"); Object[] row = new Object[3]; ImbalancedFeature current; double freq; String truncate; for (int i = 0; i < dataset.getNumLabels(); i++) { current = labelAppearances[i]; row[0] = current.getName(); freq = current.getAppearances() * 1.0 / dataset.getNumInstances(); row[1] = current.getAppearances(); truncate = Double.toString(freq); row[2] = MetricUtils.getValueFormatted(truncate, 4); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(80); tcm.getColumn(1).setPreferredWidth(70); tcm.getColumn(2).setPreferredWidth(50); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Generates TableModel for labels per example values * //from ww w. j ava 2 s . com * @param jtable Table * @param labelsPerExample Number of labels per example * @return Generated TableModel */ private TableModel labelsPerExampleTableModel(JTable jtable, HashMap<Integer, Integer> labelsPerExample) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("# Labels"); tableModel.addColumn("# Examples"); tableModel.addColumn("Frequency"); Object[] row = new Object[3]; double freq; int freqCurrent; String truncate; int max = Utils.maxKey(labelsPerExample); for (int i = 0; i <= max; i++) { freqCurrent = 0; if (labelsPerExample.get(i) != null) { freqCurrent = labelsPerExample.get(i); } freq = freqCurrent * 1.0 / dataset.getNumInstances(); row[0] = i; row[1] = freqCurrent; truncate = Double.toString(freq); row[2] = MetricUtils.getValueFormatted(truncate, 4); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(80); tcm.getColumn(1).setPreferredWidth(50); tcm.getColumn(2).setPreferredWidth(70); return jtable.getModel(); }
From source file:interfaces.InterfazPrincipal.java
private void botonGenerarReporteClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGenerarReporteClienteActionPerformed // TODO add your handling code here: try {/*from ww w . j a v a 2s.co m*/ if (clienteReporteClienteFechaFinal.getSelectedDate().getTime() .compareTo(clienteReporteClienteFechaInicial.getSelectedDate().getTime()) < 0) { JOptionPane.showMessageDialog(this, "La fecha final debe ser posterior al dia de inicio"); } else { final ArrayList<Integer> listaIDFlujos = new ArrayList<>(); final JDialog dialogoEditar = new JDialog(); dialogoEditar.setTitle("Reporte cliente"); dialogoEditar.setSize(350, 610); dialogoEditar.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); //c.fill = GridBagConstraints.HORIZONTAL; JLabel ediitarTextoPrincipalDialogo = new JLabel("Informe cliente"); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.insets = new Insets(10, 45, 10, 10); Font textoGrande = new Font("Arial", 1, 18); ediitarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(ediitarTextoPrincipalDialogo, c); final JTable tablaDialogo = new JTable(); DefaultTableModel modeloTabla = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //all cells false return false; } }; ; modeloTabla.addColumn("Factura"); modeloTabla.addColumn("Tipo Flujo"); modeloTabla.addColumn("Fecha"); modeloTabla.addColumn("Valor"); //Llenar tabla ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura( " where factura_id in (select factura_id from Factura where cliente_id = " + String.valueOf(jTextFieldIdentificacionClienteReporte.getText()) + ") order by factura_id"); // {"flujo_id","factura_id","tipo_flujo","fecha","valor"}; ArrayList<Calendar> fechasFlujos = new ArrayList<>(); for (int i = 0; i < flujosCliente.size(); i++) { String fila[] = new String[4]; String[] objeto = flujosCliente.get(i); fila[0] = objeto[1]; fila[1] = objeto[2]; fila[2] = objeto[3]; fila[3] = objeto[4]; //Filtrar, mirar las fechas String[] partirEspacios = objeto[3].split("\\s"); //El primer string es la fecha sin hora //Ahora esparamos por - String[] tomarAgeMesDia = partirEspacios[0].split("-"); //Realizar filtro int ageConsulta = Integer.parseInt(tomarAgeMesDia[0]); int mesConsulta = Integer.parseInt(tomarAgeMesDia[1]); int diaConsulta = Integer.parseInt(tomarAgeMesDia[2]); //Obtenemos dias, mes y ao de la consulta //Inicial int anioInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.YEAR); int mesInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.MONTH) + 1; int diaInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.DAY_OF_MONTH); //Final int anioFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.YEAR); int mesFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.MONTH) + 1; int diaFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.DAY_OF_MONTH); //Construir fechas Calendar fechaDeLaBD = new GregorianCalendar(ageConsulta, mesConsulta, diaConsulta); //Set year, month, day) Calendar fechaInicialRango = new GregorianCalendar(anioInicial, mesInicial, diaInicial); Calendar fechaFinalRango = new GregorianCalendar(anioFinal, mesFinal, diaFinal); if (fechaDeLaBD.compareTo(fechaInicialRango) <= 0 && fechaDeLaBD.compareTo(fechaFinalRango) >= 0) { fechasFlujos.add(fechaDeLaBD); modeloTabla.addRow(fila); } } if (modeloTabla.getRowCount() > 0) { tablaDialogo.setModel(modeloTabla); tablaDialogo.getColumn("Factura").setMinWidth(80); tablaDialogo.getColumn("Tipo Flujo").setMinWidth(80); tablaDialogo.getColumn("Fecha").setMinWidth(90); tablaDialogo.getColumn("Valor").setMinWidth(80); tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(tablaDialogo); scroll.setPreferredSize(new Dimension(330, 150)); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.insets = new Insets(0, 0, 0, 0); panelDialogo.add(scroll, c); TimeSeries localTimeSeries = new TimeSeries("Compras del cliente en el periodo"); Map listaAbonos = new HashMap(); for (int i = 0; i < modeloTabla.getRowCount(); i++) { listaIDFlujos.add(Integer.parseInt(flujosCliente.get(i)[0])); if (modeloTabla.getValueAt(i, 1).equals("abono")) { Calendar fechaFlujo = fechasFlujos.get(i); double valor = Double.parseDouble(String.valueOf(modeloTabla.getValueAt(i, 3))); int anoDato = fechaFlujo.get(Calendar.YEAR); int mesDato = fechaFlujo.get(Calendar.MONTH) + 1; int diaDato = fechaFlujo.get(Calendar.DAY_OF_MONTH); Day FechaDato = new Day(diaDato, mesDato, anoDato); if (listaAbonos.get(FechaDato) != null) { double valorAbono = (double) listaAbonos.get(FechaDato); listaAbonos.remove(FechaDato); listaAbonos.put(FechaDato, valorAbono + valor); } else { listaAbonos.put(FechaDato, valor); } } } Double maximo = 0.0; Iterator iterator = listaAbonos.keySet().iterator(); while (iterator.hasNext()) { Day key = (Day) iterator.next(); Double value = (double) listaAbonos.get(key); maximo = Math.max(maximo, value); localTimeSeries.add(key, value); } //localTimeSeries.add(); TimeSeriesCollection datos = new TimeSeriesCollection(localTimeSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart("Compras del cliente en el periodo", // Title "Tiempo", // x-axis Label "Total ($)", // y-axis Label datos, // Dataset true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); /*Altering the graph */ XYPlot plot = (XYPlot) chart.getPlot(); plot.setAxisOffset(new RectangleInsets(5.0, 10.0, 10.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setRange(new Range(0, maximo * 1.2)); Font font = new Font("Dialog", Font.PLAIN, 9); numberAxis.setTickLabelFont(font); numberAxis.setLabelFont(font); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); axis.setAutoTickUnitSelection(false); axis.setVerticalTickLabels(true); axis.setTickLabelFont(font); axis.setLabelFont(font); LegendTitle leyendaChart = chart.getLegend(); leyendaChart.setItemFont(font); Font fontTitulo = new Font("Dialog", Font.BOLD, 12); TextTitle tituloChart = chart.getTitle(); tituloChart.setFont(fontTitulo); ChartPanel CP = new ChartPanel(chart); Dimension D = new Dimension(330, 300); CP.setPreferredSize(D); CP.setVisible(true); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.insets = new Insets(10, 0, 0, 0); panelDialogo.add(CP, c); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(10, 30, 0, 0); JButton botonCerrar = new JButton("Cerrar"); botonCerrar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEditar.dispose(); } }); panelDialogo.add(botonCerrar, c); JButton botonGenerarPDF = new JButton("Guardar archivo"); botonGenerarPDF.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente(); reporteFlujosCliente.guardarDocumentoDialogo(dialogoEditar, listaIDFlujos, Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()), clienteReporteClienteFechaInicial.getSelectedDate(), clienteReporteClienteFechaFinal.getSelectedDate()); } }); c.insets = new Insets(10, 100, 0, 0); panelDialogo.add(botonGenerarPDF, c); JButton botonImprimir = new JButton("Imprimir"); botonImprimir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente(); reporteFlujosCliente.imprimirFlujo(listaIDFlujos, Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()), clienteReporteClienteFechaInicial.getSelectedDate(), clienteReporteClienteFechaFinal.getSelectedDate()); } }); c.insets = new Insets(10, 230, 0, 0); panelDialogo.add(botonImprimir, c); dialogoEditar.add(panelDialogo); dialogoEditar.setVisible(true); } else { JOptionPane.showMessageDialog(this, "El cliente no registra movimientos en el rango de fechas seleccionado"); } } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Debe seleccionar un da inicial y final de fechas"); } }
From source file:app.RunApp.java
/** * Generates TableModel for imbalanced data * /*from w w w. j av a2 s .co m*/ * @param jtable Table * @param dataset Multi-label dataset * @return Generated TableModel */ private TableModel imbalancedTableModel(JTable jtable, MultiLabelInstances dataset) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("IR intra class"); tableModel.addColumn("IR inter class"); tableModel.addColumn("STDEV intra class"); imbalancedLabels = MetricUtils.sortImbalancedDataByIRIntraClass(imbalancedLabels); Object[] row = new Object[4]; double std; String truncate; ImbalancedFeature current; for (int i = 0; i < dataset.getNumLabels(); i++) { current = imbalancedLabels[i]; row[0] = current.getName(); truncate = Double.toString(current.getIRIntraClass()); row[1] = MetricUtils.truncateValue(truncate, 5); truncate = Double.toString(current.getIRInterClass()); row[2] = MetricUtils.truncateValue(truncate, 5); std = Math.sqrt(current.getVariance()); row[3] = MetricUtils.truncateValue(std, 4); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(100); tcm.getColumn(1).setPreferredWidth(20); tcm.getColumn(2).setPreferredWidth(80); tcm.getColumn(3).setPreferredWidth(40); return jtable.getModel(); }
From source file:com.view.PortfolioManagerWindow.java
private void PMSendOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PMSendOrderActionPerformed DefaultTableModel dtm = (DefaultTableModel) PMSendOrderTable.getModel(); int nRow = dtm.getRowCount(); long currUID = 0; int nCol = dtm.getColumnCount(); Object[][] tableData = new Object[nRow][nCol]; List<SingleOrder> parsedOrders = new ArrayList(); String selectedTrader = String.valueOf(PMSelectTraderOptions.getSelectedItem()); for (int t = 0; t < traderListForBox.size(); t++) { if (traderListForBox.get(t).getUsername().equals(selectedTrader)) { currUID = traderListForBox.get(t).getU_id(); System.out.println("OUR TRADER WE ASSIGN TO IS: " + selectedTrader + " HIS ID IS: " + currUID); }/* ww w . j av a 2 s .co m*/ } boolean thereAreOrders = false; boolean ignoreRowFlag = false; for (int i = 0; i < nRow; i++) { for (int j = 0; j < nCol; j++) { tableData[i][j] = dtm.getValueAt(i, j); } System.out.println("Retrieved all table data"); boolean trigg = true; for (int k = 0; k < nCol; k++) { if (tableData[i][k] != null) { ignoreRowFlag = false; } else { ignoreRowFlag = true; System.out.println("IGNORING EMPTY ROW"); } } //double check symbol is not null if (ignoreRowFlag == false) { if (tableData[i][2] == null) { trigg = false; } else if (tableData[i][2].toString().trim().equals("")) { showMessageDialog(null, "Please enter non-empty Symbol."); trigg = false; } else if (!(tableData[i][2].toString().trim() .equals(tableData[i][2].toString().trim().toUpperCase()))) { showMessageDialog(null, "Please enter the Symbol in all capital letters."); trigg = false; } if (tableData[i][0] != null && tableData[i][1] != null && tableData[i][2] != null && tableData[i][3] != null && tableData[i][4] != null && tableData[i][5] != null) { if (tableData[i][0] != null) { long portIDC = (long) tableData[i][0]; if (portIDC < 0) { showMessageDialog(null, "You have entered a negative portfolio ID value. Please fix this value before submitting the order."); trigg = false; } } if (tableData[i][3] != null) { int quantityC = (int) tableData[i][3]; if (quantityC < 0) { showMessageDialog(null, "You have entered a negative quantity value. Please fix this value before submitting the order."); trigg = false; } } if (tableData[i][5] != null) { String orderType = (String) tableData[i][5]; switch (orderType) { case "Market": if ((tableData[i][6] != null && tableData[i][7] != null) || (tableData[i][6] != null && tableData[i][7] == null) || (tableData[i][6] == null && tableData[i][7] != null)) { showMessageDialog(null, "A market order should have neither a stop price nor a limit price."); trigg = false; } break; case "Limit": if ((tableData[i][6] != null && tableData[i][7] == null) || (tableData[i][6] != null && tableData[i][7] != null) || (tableData[i][6] == null && tableData[i][7] == null)) { showMessageDialog(null, "A limit order should have a limit price and no stop price."); trigg = false; } break; case "Stop": if ((tableData[i][6] == null && tableData[i][7] != null) || (tableData[i][6] != null && tableData[i][7] != null) || (tableData[i][6] == null && tableData[i][7] == null)) { showMessageDialog(null, "A stop order should have a stop price and no limit price."); trigg = false; } break; case "Stop Limit": if ((tableData[i][6] == null && tableData[i][7] == null) || (tableData[i][6] != null && tableData[i][7] == null) || (tableData[i][6] == null && tableData[i][7] != null)) { showMessageDialog(null, "A Stop Limit order should have both a stop price and a limit price."); trigg = false; } break; default: showMessageDialog(null, "Something messed up in cases for order type."); } } if (tableData[i][6] != null) { double stopC = (double) tableData[i][6]; if (stopC < 0) { showMessageDialog(null, "You have entered a negative stop price value. Please fix this value before submitting the order."); trigg = false; } } if (tableData[i][7] != null) { double limitC = (double) tableData[i][7]; if (limitC < 0) { showMessageDialog(null, "You have entered a negative limit price value. Please fix this value before submitting the order."); trigg = false; } } if (trigg == true) { thereAreOrders = true; SingleOrder o = new SingleOrder(tableData[i]); parsedOrders.add(o); } } else { String a, b, c, d, e, f; if (tableData[i][0] == null) { a = "Portfolio ID"; } else { a = ""; } if (tableData[i][1] == null) { b = "Stock Exchange"; } else { b = ""; } if (tableData[i][2] == null || tableData[i][2].toString().trim().equals("")) { c = "Symbol"; } else { c = ""; } if (tableData[i][3] == null) { d = "Quantity"; } else { d = ""; } if (tableData[i][4] == null) { e = "Action"; } else { e = ""; } if (tableData[i][5] == null) { f = "Order Type"; } else { f = ""; } showMessageDialog(null, "You need to fill in the necessary fields before sending the order:\n" + a + "\n" + b + "\n" + c + "\n" + d + "\n" + e + "\n" + f); } } } if (thereAreOrders) { showMessageDialog(null, "You have successfully sent your trades."); dtm.setRowCount(0); dtm.addRow(new Object[] { null, null, null, null, null, null, null, null, null }); Order toSend = new Order(selectedTrader, parsedOrders); toSend.setAssignedTo(currUID); Long currID = CMAIN.reportUser().getU_id(); String currUname = CMAIN.reportUser().getUsername(); toSend.setPmId(currID); toSend.setPmUsername(currUname); ControllerPMCreatedOrders.handleOrder(toSend); } }
From source file:com.peterbochs.PeterBochsDebugger.java
protected void updateAddressTranslate() { try {/*from w ww. j a v a 2 s .co m*/ jStatusLabel.setText("Updating Address translate"); // commandReceiver.setCommandNoOfLine(-1); commandReceiver.clearBuffer(); commandReceiver.shouldShow = false; sendCommand("info tab"); Thread.currentThread(); String result = commandReceiver.getCommandResultUntilEnd(); String[] lines = result.split("\n"); DefaultTableModel model = (DefaultTableModel) jAddressTranslateTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } for (int x = 1; x < lines.length; x++) { Vector<String> strs = new Vector<String>(Arrays.asList(lines[x].trim().split("->"))); model.addRow(strs); } ((DefaultTableModel) jAddressTranslateTable.getModel()).fireTableDataChanged(); } catch (Exception ex) { ex.printStackTrace(); } }