List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:semaforo.Semaforo.java
public synchronized void loadTableTickers() { Settings settings = Controller.getSettings(); 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(); TableTicker.setRowHeight(20); //40 TableTicker.setFont(new Font("Arial", Font.BOLD, 12)); //18 TableTicker.getColumnModel().getColumn(0).setPreferredWidth(10); TableTicker.getColumnModel().getColumn(1).setPreferredWidth(30); JTableHeader header = TableTicker.getTableHeader(); header.setPreferredSize(new Dimension(100, 30)); TableTicker.getTableHeader().setFont(new Font("Arial", Font.BOLD, 15)); Object[] o = new Object[2]; for (int i = 0; i < settings.getTickers().size(); i++) { o[0] = settings.getTickers().get(i).getName(); o[1] = 0;// w w w . j ava 2s . c o m model.addRow(o); } }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
private void updateMetaDataTable() { DefaultTableModel model = (DefaultTableModel) metaDataTable.getModel(); model.setNumRows(0);//from ww w . j a va2 s .c o m for (MetaDataColumn column : currentChannel.getProperties().getMetaDataColumns()) { model.addRow(new Object[] { column.getName(), column.getType(), column.getMappingName() }); } revertMetaDataButton.setEnabled(false); }
From source file:Sales.TabbedPaneWin.java
private void addToCartBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToCartBtnActionPerformed String itemCode = null, itemName; double unitPrice, totalAmount; int saleQty = 0; try {/*from w w w . j a va2 s.c o m*/ itemCode = selectItemsTable.getValueAt(selectItemsTable.getSelectedRow(), 0).toString(); } catch (ArrayIndexOutOfBoundsException e) { JOptionPane.showMessageDialog(null, "Error: Select a row.."); } if (selectItemsTable.getSelectedRow() != -1) { itemCode = selectItemsTable.getValueAt(selectItemsTable.getSelectedRow(), 0).toString(); itemName = selectItemsTable.getValueAt(selectItemsTable.getSelectedRow(), 1).toString(); unitPrice = Double .parseDouble(selectItemsTable.getValueAt(selectItemsTable.getSelectedRow(), 3).toString()); try { saleQty = Integer.parseInt(saleQtyTxtF.getText()); } catch (NumberFormatException e) { } if (Validate.isValidSaleAmount(saleQty)) { saleQtyTxtF.setText(""); totalAmount = (unitPrice * saleQty); //adding row to client cart DefaultTableModel model = (DefaultTableModel) clientCartTable.getModel(); model.addRow(new Object[] { itemCode, itemName, unitPrice, saleQty, totalAmount }); totalAmount = Double.valueOf(totAmountLbl1.getText()) + totalAmount; totAmountLbl1.setText(Double.toString(totalAmount)); grandTotalLbl1.setText(totAmountLbl1.getText()); //visibleing Jbuttons if (clientCartTable.getRowCount() == 0) { removeSelectedBtn.setEnabled(false); ClearCartBtn.setEnabled(false); } else { removeSelectedBtn.setEnabled(true); ClearCartBtn.setEnabled(true); } } else { jLabel80.setVisible(true); JOptionPane.showMessageDialog(null, "Enter Valid Sale Qty..."); } } else { JOptionPane.showMessageDialog(null, "Error: Select a row From Selected Items Table.."); } jLabel80.setVisible(false); }
From source file:com.osparking.attendant.AttListForm.java
/** * Update attendant listing table by accessing database table. * It also //from w w w. ja v a2 s .c o m * @return */ private int loadAttendantTable(String newID) { DefaultTableModel model = (DefaultTableModel) usersTable.getModel(); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; StringBuilder sb = new StringBuilder(); sb.append("Select id as 'User ID', name as 'Name', "); sb.append("if(isManager, 'Y', 'N') as 'Manager', "); sb.append("cellphone as 'Cell', phone as 'Phone', email as 'E-mail', "); sb.append("date_format(creationTime, '%Y-%m-%d') as 'Created', "); sb.append("date_format(lastModiTime, '%Y-%m-%d') as 'Modified' "); sb.append("from users_osp"); prevSearchColumn = currSearchColumn; prevSearchString = currSearchString; if (currSearchString.length() > 0) { if (currSearchColumn == LOGIN_ID_LABEL) { sb.append(" Where ID like ? "); } else { sb.append(" Where Name like ? "); } if (newID.length() > 0) { sb.append("or (ID = ?)"); } } try { conn = JDBCMySQL.getConnection(); pstmt = conn.prepareStatement(sb.toString()); int index = 1; if (currSearchString.length() > 0) { pstmt.setString(index++, "%" + currSearchString + "%"); if (newID.length() > 0) { pstmt.setString(index++, newID); } } rs = pstmt.executeQuery(); model.setRowCount(0); while (rs.next()) { model.addRow(new Object[] { rs.getString("User ID"), rs.getString("Name"), rs.getString("Manager"), rs.getString("Cell"), rs.getString("Phone"), rs.getString("E-mail"), rs.getString("Created"), rs.getString("Modified") }); } } catch (Exception ex) { logParkingException(Level.SEVERE, ex, "(refresh user list displaying table)"); } finally { closeDBstuff(conn, pstmt, rs, "(refresh user list displaying table)"); adjustTableHeight(usersTable); countValue.setText(String.valueOf(usersTable.getRowCount())); if (newID.length() > 0 && newIDnotSatisfySearchCondition(newID)) { searchButton.setEnabled(true); } else { searchButton.setEnabled(false); } return model.getRowCount(); } }
From source file:semaforo.Semaforo.java
public synchronized void loadTableWeek(JTable TableWeek, int index) { Settings settings = Controller.getSettings(); //TableWeek.getColumnModel().getColumn(0).setPreferredWidth(350); //150 TableWeek.setRowHeight(20); //40 //TableWeek.getColumnModel().getColumn(9).setPreferredWidth(350);//150 TableWeek.setFont(new Font("Arial", Font.BOLD, 12));//18 CustomRenderer cr = new CustomRenderer(TableWeek.getDefaultRenderer(Object.class), Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY); TableWeek.setDefaultRenderer(Object.class, cr); DefaultTableModel model = (DefaultTableModel) TableWeek.getModel(); Object[] o = new Object[10]; JTableHeader header = TableWeek.getTableHeader(); header.setPreferredSize(new Dimension(10, 30)); //100 TableWeek.getTableHeader().setFont(new Font("Arial", Font.BOLD, 15)); /* DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); centerRenderer.setHorizontalAlignment(SwingConstants.CENTER); TableWeek.getColumnModel().getColumn(0).setCellRenderer(centerRenderer); TableWeek.getColumnModel().getColumn(9).setCellRenderer(centerRenderer); TableWeek.setDefaultRenderer(String.class, centerRenderer);*/ int num = settings.getTickers().size(); /* while(DDBB.loadData) { try {/*www. j ava2 s .c o m*/ Thread.sleep(500); } catch (InterruptedException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } }*/ if (TableWeek.getModel().getRowCount() > 0) { num = Math.min(settings.getTickers().size(), TableWeek.getModel().getRowCount()); } for (int i = 0; i < num; i++) { o[0] = settings.getTickers().get(i).getMinValue(index); o[9] = settings.getTickers().get(i).getMaxValue(index); model.addRow(o); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
public void fireAddTargetEvent(Village pTarget, int pAmount) { DefaultTableModel victimModel = (DefaultTableModel) jVictimTable.getModel(); if (pTarget != null) { boolean contains = false; for (int row = 0; row < jVictimTable.getRowCount(); row++) { if (jVictimTable.getValueAt(row, 1).equals(pTarget)) { contains = true;//from w w w . j a v a2 s . c om jVictimTable.setValueAt(pAmount, row, 3); break; } } if (!contains) { victimModel.addRow( new Object[] { pTarget.getTribe(), pTarget, jMarkTargetAsFake.isSelected(), pAmount, 0 }); } } updateInfo(); victimModel.fireTableDataChanged(); }
From source file:Clavis.Windows.WShedule.java
public synchronized void refreshTable(int val) { DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (modelo.getRowCount() > 0) { int tam = modelo.getRowCount(); for (int h = 0; h < tam; h++) { modelo.removeRow(0);//from w w w . j a va 2s . c o m } } java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>(); if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); } lista = new java.util.ArrayList<>(); andamento = 0; switch (val) { case 0: estado = lingua.translate("Todos"); for (Keys.Request req : requisicoes) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } break; case 1: estado = lingua.translate("terminado"); for (Keys.Request req : requisicoes) { if (req.isTerminated()) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 2: estado = lingua.translate("no realizado"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 3: estado = lingua.translate("por realizar"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && (!req.isTerminated()) && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; } valores = new String[lista.size()][4]; for (int i = 0; i < lista.size(); i++) { String[] multipla = lista.get(i).getActivity().split(":::"); String saux = multipla[0]; if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - " + lista.get(i).getTimeEnd().toString(0); valores[i][2] = lista.get(i).getBeginDate().toString(); valores[i][3] = saux + " - " + lista.get(i).getSubject().getName(); } else { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getBeginDate().toString(); valores[i][2] = lista.get(i).getEndDate().toString(); valores[i][3] = saux; } } }
From source file:GUI.AllForDealFrame.java
private void btnAjoutSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAjoutSActionPerformed // TODO add your handling code here: lerror.setText(" "); Service s = new Service(); Date date = new java.sql.Date(System.currentTimeMillis()); s.setUserId(LoginForm.getUser_id()); if (!tfNomS.getText().trim().equals("")) { s.setNomService(tfNomS.getText()); try {//from www .ja v a2s .c o m rsId = zoneDAO.getZoneByName(cbZone2.getSelectedItem().toString()); while (rsId.next()) { s.setZone(rsId.getInt(1)); } } catch (SQLException ex) { Logger.getLogger(AllForDealFrame.class.getName()).log(Level.SEVERE, null, ex); } try { rsIdCol = coldao.getCollectionByName(cbCat.getSelectedItem().toString()); while (rsIdCol.next()) { s.setType(rsIdCol.getInt(1)); } } catch (SQLException ex) { Logger.getLogger(AllForDealFrame.class.getName()).log(Level.SEVERE, null, ex); } s.setDescription(tfDescription.getText()); // s.setType(cbCat.getSelectedItem()); //s.setZone((int) cbZone.getSelectedItem()); s.setDateAjout(date); s.setEtat("EnCours"); ServiceDao sdao = new ServiceDao(); System.out.println(rsIdCol); sdao.add(s); DefaultTableModel model = (DefaultTableModel) tblService.getModel(); model.addRow(new Object[] { tfNomS.getText(), tfDescription.getText(), cbCat.getSelectedItem().toString(), s.getDateAjout(), s.getEtat() }); tfNomS.setText(null); tfDescription.setText(null); cbCat.setSelectedItem(null); cbZone2.setSelectedItem(null); tblMesServices.setModel(new ServiceByUserIdModel()); } else { lerror.setText(" Veuiller enter le nom de votre service SVP !"); tblAllServices.setModel(new ListeService()); tblAllServices.getColumnModel().getColumn(0).setMinWidth(0); tblAllServices.getColumnModel().getColumn(0).setMaxWidth(0); tblAllServices.getColumnModel().getColumn(0).setWidth(0); tblMesServices.setModel(new ServiceByUserIdModel()); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
private void sourceFromInternalClipboardAction() { String data = ""; try {/* w w w. j a v a 2 s . com*/ data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null) .getTransferData(DataFlavor.stringFlavor); String[] lines = data.split("\n"); int cnt = 0; DefaultTableModel theModel = (DefaultTableModel) jSourcesTable.getModel(); for (String line : lines) { String[] split = line.split(";"); Village v = DataHolder.getSingleton().getVillagesById().get(Integer.parseInt(split[0])); if (v.getTribe() != Barbarians.getSingleton()) { UnitHolder unit = DataHolder.getSingleton().getUnitByPlainName(split[1]); Boolean fake = Boolean.parseBoolean(split[2]); if (v != null && unit != null) { theModel.addRow(new Object[] { v, unit, fake, 0 }); cnt++; } } } showSuccess(cnt + ((cnt == 1) ? " Eintrag eingefgt" : " Eintrge eingefgt")); } catch (UnsupportedFlavorException ufe) { logger.error("Failed to copy data from internal clipboard", ufe); showError("Fehler beim Einfgen aus der Zwischenablage"); } catch (IOException ioe) { logger.error("Failed to copy data from internal clipboard", ioe); showError("Fehler beim Einfgen aus der Zwischenablage"); } catch (NumberFormatException nfe) { //invalid paste, try village parser List<Village> villages = PluginManager.getSingleton().executeVillageParser(data); if (!villages.isEmpty()) { UnitHolder unit = (UnitHolder) jTroopsList.getSelectedItem(); if (unit == null) { unit = DataHolder.getSingleton().getUnitByPlainName("ram"); } addSourceVillages(villages, (UnitHolder) jTroopsList.getSelectedItem(), jMarkAsFakeBox.isSelected()); } else { showInfo("Keine verwendbaren Daten in der Zwischenablage gefunden"); } } }
From source file:forms.FormFluxodeCaixa.java
public List<CarCapContas> CarregarGraficoJTable(String nome, TipoGrafico tipografico, int posicao, TipoConta tipoconta, Date DataInicial, Date DataFinal, FiltroData filtro) { //Calendar c2 = Calendar.getInstance(); // posicao = 1 (esquerda), posicao = 2 (direita), posicao 3 = JTable direita if (posicao == 1) { if (tipografico.equals(TipoGrafico.barras) || tipografico.equals(TipoGrafico.pizza)) { Graficos grap = new Graficos(tipo, this.titulo); JFreeChart j = null;//from w w w .ja va 2 s .c om if (tipografico.equals(TipoGrafico.barras)) { j = grap.GraficoBarras(contas, "Entradas X Saidas", filtro, "full", dataInicial, dataFinal); } else if (tipografico.equals(TipoGrafico.pizza)) { j = grap.GraficoPizza("Grfico de Pizza", contas, filtro); } ChartPanel chart = new ChartPanel(j); WebPanelGrafico.removeAll(); webPanel_Split.validate(); int largura = WebPanelGrafico.getWidth(); int altura = WebPanelGrafico.getHeight(); WebPanelGrafico.setBounds(0, 0, largura, altura); chart.setBounds(0, 0, largura, altura); chart.addPropertyChangeListener(null); WebPanelGrafico.add(chart); WebPanelGrafico.revalidate(); WebPanelGrafico.repaint(); } else { Graficos grap = new Graficos(tipo, this.titulo); ChartPanel c = grap.informarDadosGrafico("grafico", contas); WebPanelGrafico.removeAll(); webPanel_Split.validate(); int largura = WebPanelGrafico.getWidth(); int altura = WebPanelGrafico.getHeight(); WebPanelGrafico.setBounds(0, 0, largura, altura); c.setBounds(0, 0, largura, altura); c.addPropertyChangeListener(null); WebPanelGrafico.add(c); WebPanelGrafico.revalidate(); WebPanelGrafico.repaint(); } } else if (posicao == 2) { if (tipografico.equals(TipoGrafico.barras) || tipografico.equals(TipoGrafico.pizza)) { Graficos grap = new Graficos(tipo, this.titulo); JFreeChart j = null; if (tipografico.equals(TipoGrafico.barras)) { j = grap.GraficoBarras(contas, "Entradas X Saidas", filtro, "full", dataInicial, dataFinal); } else if (tipografico.equals(TipoGrafico.pizza)) { j = grap.GraficoPizza("Grfico de Pizza", contas, filtro); } ChartPanel chart = new ChartPanel(j); webPanel_Tabela.removeAll(); webPanel_Split.validate(); int largura = webPanel_Tabela.getWidth(); int altura = webPanel_Tabela.getHeight(); webPanel_Tabela.setBounds(0, 0, largura, altura); chart.setBounds(0, 0, largura, altura); webPanel_Tabela.add(chart); webPanel_Tabela.revalidate(); webPanel_Tabela.repaint(); } else { Graficos grap = new Graficos(tipo, this.titulo); ChartPanel c = grap.informarDadosGrafico("grafico", contas); webPanel_Tabela.removeAll(); webPanel_Split.validate(); int largura = webPanel_Tabela.getWidth(); int altura = webPanel_Tabela.getHeight(); webPanel_Tabela.setBounds(0, 0, largura, altura); c.setBounds(0, 0, largura, altura); webPanel_Tabela.add(c); webPanel_Tabela.revalidate(); webPanel_Tabela.repaint(); } } else if (posicao == 3) { double totalEntradas = 0; double totalSaidas = 0; double totalDisponivel = 0; double valorEntrada = 0; double valorSaida = 0; String valorSaidaFinal = null; String valorEntradaFinal = null; String SaldoDia = null; WebTable tablenovo = new WebTable(); DefaultTableModel modelTabela = new DefaultTableModel( new Object[] { "Data", "Entradas", "Sadas", "Saldo do Dia" }, 0); // Tive que criar esse cara por que o valor da data final de perdia ao clicar em filtrar String dataInicialSetada = Utils.formatData(txtDataInicial.getDate()); String dataFinalsetada = Utils.formatData(txtDataFinal.getDate()); int intervaloDatas = new utils.Utils().diasEntreDatas(dataInicialSetada, dataFinalsetada); // aqui eu seto o valor que estava novamente no campo, no sei por que ele ta perdendo o valor :/ txtDataFinal.setText(dataFinalsetada); txtDataInicial.setText(dataInicialSetada); Date dataAtualdoLoop; Calendar c = Calendar.getInstance(); c.setTime(dataInicial); for (int j = 0; j <= intervaloDatas; j++) { totalEntradas = 0; totalSaidas = 0; dataAtualdoLoop = c.getTime(); for (CarCapContas i : contas) { System.out.println("data 1:" + Utils.formatData(dataAtualdoLoop) + "data2: " + Utils.formatData(i.getContaDataEmissao())); if (Utils.formatData(dataAtualdoLoop).equals(Utils.formatData(i.getContaDataEmissao()))) { if (i.getContaTipo().equals(TipoConta.Entrada)) { valorEntrada += i.getContaValorPago(); } else { valorSaida += i.getContaValorPago(); } valorSaidaFinal = Utils.formatDouble.format(valorSaida); valorEntradaFinal = Utils.formatDouble.format(valorEntrada); SaldoDia = Utils.formatDouble.format(valorEntrada - valorSaida); if (valorSaida == 0.00) { valorSaidaFinal = ""; } else if (valorEntrada == 0.00) { valorEntradaFinal = ""; } else if (valorEntrada - valorSaida == 0.00) { SaldoDia = ""; } } if (i.getContaTipo().equals(TipoConta.Entrada)) { totalEntradas += i.getContaValorPago(); } else if (i.getContaTipo().equals(TipoConta.Saida)) { totalSaidas += i.getContaValorPago(); } } if (SaldoDia != null) { Object[] data = { Utils.formatData(dataAtualdoLoop), valorEntradaFinal, valorSaidaFinal, SaldoDia }; modelTabela.addRow(data); valorEntradaFinal = null; valorSaidaFinal = null; valorEntrada = 0; valorSaida = 0; SaldoDia = null; } c.add(Calendar.DATE, +1); } tablenovo.setModel(modelTabela); TableCellRenderer renderer = new ColorCells(true); tablenovo.setDefaultRenderer(String.class, renderer); tablenovo.setDefaultRenderer(Integer.class, renderer); tablenovo.setDefaultRenderer(BigDecimal.class, renderer); tablenovo.setDefaultRenderer(Date.class, renderer); tablenovo.setDefaultRenderer(Object.class, renderer); txtTotalEntradas.setText(String.valueOf(Utils.format(totalEntradas))); txtTotalSaidas.setText(String.valueOf(Utils.format(totalSaidas))); txtTotal.setText(String.valueOf(Utils.format(totalEntradas - totalSaidas))); JScrollPane tableContainer = new JScrollPane(tablenovo); webPanel_Tabela.removeAll(); webPanel_Split.validate(); int largura = webPanel_Tabela.getWidth(); int altura = webPanel_Tabela.getHeight(); webPanel_Tabela.setBounds(0, 0, largura, altura); tableContainer.setBounds(0, 0, largura, altura); webPanel_Tabela.add(tableContainer); webPanel_Tabela.revalidate(); webPanel_Tabela.repaint(); } else if (posicao == 4) { return contas; } return null; }