public void atualizaLista(JTable lista, String nome) throws DaoException { DefaultTableModel dtm = (DefaultTableModel) table.getModel(); ImageIcon editar = new ImageIcon(CadFuncionario.class.getResource("/br/com/images/editar.png")); ImageIcon excluir = new ImageIcon(CadFuncionario.class.getResource("/br/com/images/icon_excluir.png")); ImageIcon relatorio = new ImageIcon(CadFuncionario.class.getResource("/br/com/images/repo.png")); // mudar icon TableColumnModel columnModel = table.getColumnModel(); JTableRenderer renderer = new JTableRenderer(); JTableRenderer renderer1 = new JTableRenderer(); JTableRenderer renderer2 = new JTableRenderer(); renderer.setValue(editar); renderer.setHorizontalAlignment(JLabel.CENTER); columnModel.getColumn(5).setCellRenderer(renderer); renderer1.setValue(excluir); renderer1.setHorizontalAlignment(JLabel.CENTER); columnModel.getColumn(7).setCellRenderer(renderer1); renderer2.setValue(relatorio); renderer2.setHorizontalAlignment(JLabel.CENTER); columnModel.getColumn(6).setCellRenderer(renderer2); dtm.setRowCount(0); List<FolhaPagamento> listaFolha = new ArrayList<FolhaPagamento>(); listaFolha = folhaDao.consultarPagamento(nome); String dados[] = new String[5]; for (FolhaPagamento obj : listaFolha) { dados[0] = String.valueOf(obj.getCodDep()); dados[1] = obj.getNomeFunc(); dados[2] = obj.getProfissaoFunc(); dados[3] = String.valueOf(obj.getTotalFunc()); dados[4] = String.valueOf(obj.getDataInicio()) + " / " + String.valueOf(obj.getDataFim()); ((DefaultTableModel) table.getModel()).addRow(dados); } table.setDefaultRenderer(Object.class, new TableCellRenderer()); table.repaint(); }
public void atualizaFormulario(FolhaPagamento objFolha) { textField_9.setText(objFolha.getNomeFunc()); textField.setText(objFolha.getNumFunc().toString()); textField_3.setText(objFolha.getSalarioFunc().toString()); textField_1.setText(objFolha.getProfissaoFunc()); textField_2.setText(objFolha.getComissaoFuncTotal().toString()); textField_4.setText(objFolha.getBonusFunc().toString()); textField_6.setText(String.valueOf(objFolha.getTotalFunc())); dateInicio.setDate(objFolha.getDataInicio()); dateFim.setDate(objFolha.getDataFim()); Integer matr = objFolha.getNumFunc(); textField_5.setText(matr.toString()); lista.setVisible(false); formulario.setVisible(true); buttonPanel.setVisible(false); }