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:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * // ww w. java 2 s . c om */ protected void fillPropsTable() { TreePath path = tree.getSelectionPath(); if (path != null) { RegProcEntry rpe = (RegProcEntry) path.getLastPathComponent(); Vector<String> keys = new Vector<String>(); for (Object obj : rpe.keySet()) { keys.add(obj.toString()); } Collections.sort(keys); if (fullDescHash == null) { fullDescHash = rp.getAllDescPairsHash(); } Object[][] rows = new Object[keys.size()][2]; int inx = 0; for (Object key : keys) { String titleStr = fullDescHash.get(key); if (titleStr == null) { titleStr = key.toString(); } rows[inx][0] = titleStr; rows[inx][1] = rpe.get(key.toString()); inx++; } propsTable.setModel(new DefaultTableModel(rows, new String[] { "Property", "Value" })); } else { propsTable.setModel(new DefaultTableModel()); } }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * setup GUI layout for the data panel including datatable and summary textArea * *//*from ww w . ja v a 2 s . c om*/ protected void initTable() { tModel = new DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); dataTable = new JTable(tModel); /* System.out.println("here"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); dataTable.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.addKeyListener(this); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); headerTable.setEnabled(false); headerTable.setGridColor(Color.gray); headerTable.setShowGrid(true); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); hookTableAction(); dataPanel = new JPanel(); summaryPanel = new JTextArea(); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); Color bg = dataPanel.getBackground(); summaryPanel.setBackground(bg); summaryPanel.setEditable(false); summaryPanel.setForeground(Color.BLACK); dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * clear data panel//w ww .j a va 2 s. c o m * */ public void resetTable() { // System.out.println("resetTable get called"); for (int i = 0; i < columnNumber; i++) columnNames[i] = new String(DEFAULT_HEADER + (i + 1)); tModel = new javax.swing.table.DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); dataTable = new JTable(tModel); /* System.out.println("here2"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); heading.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1; hookTableAction(); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); summaryPanel.removeAll(); dataPanel.removeAll(); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }
From source file:br.com.jinsync.view.FrmJInSync.java
private void loadTableString() { tableString = new JTable(); List<String> campos = new ArrayList<String>(); int qtdLinhas = 0; int ind = 0;/* www.ja v a 2 s. c o m*/ int i = 0; int[] seqGrp = new int[100]; int[] qtdOccurs = new int[100]; int[] nivOccurs = new int[100]; int[] indOccurs = new int[100]; qtdLinhas = listTotCopy.size(); for (i = 0; i < qtdLinhas; i++) { Copybook cp = listTotCopy.get(i); if (Integer.parseInt(cp.getLvlField().trim()) <= nivOccurs[ind]) { if (indOccurs[ind] < qtdOccurs[ind]) { indOccurs[ind] = indOccurs[ind] + 1; i = seqGrp[ind] + 1; cp = listTotCopy.get(i); } else { indOccurs[ind] = 1; ind = ind - 1; } } if (cp.getTypeField() != "Group") { if (cp.getRedefField().contains("OCCURS")) { int pos = cp.getRedefField().indexOf("OCCURS") + 7; int posFim = cp.getRedefField().indexOf("TIMES") - 1; int qtdOc = Integer.parseInt(cp.getRedefField().substring(pos, posFim).trim()); for (int k = 1; k <= qtdOc; k++) { String val = ""; String virg = ""; val = val + virg + k; virg = ", "; val = "(" + val + ")"; campos.add(cp.getNameField().toString() + val); } } else { if (qtdOccurs[ind] > 1) { String val = ""; String virg = ""; for (int k = 1; k <= ind; k++) { val = val + virg + indOccurs[k]; virg = ", "; } val = "(" + val + ")"; campos.add(cp.getNameField().toString() + val); } else { campos.add(cp.getNameField().toString()); } } } else { if (cp.getRedefField().contains("OCCURS")) { int pos = cp.getRedefField().indexOf("OCCURS") + 7; int posFim = cp.getRedefField().indexOf("TIMES") - 1; ind = ind + 1; qtdOccurs[ind] = Integer.parseInt(cp.getRedefField().trim().substring(pos, posFim)); nivOccurs[ind] = Integer.parseInt(cp.getLvlField().trim()); seqGrp[ind] = i; indOccurs[ind] = 1; if (cp.getRedefField().contains("DEPENDING")) { pos = cp.getRedefField().indexOf("DEPENDING ON") + 13; String val = cp.getRedefField().substring(pos).trim(); for (int k = 0; k < dependField.size(); k++) { if (val.equals(dependField.get(k))) { if (dependValue.size() == 0) { qtdOccurs[ind] = 1; } else { qtdOccurs[ind] = dependValue.get(k); } } } } } } if (i == qtdLinhas - 1) { if (indOccurs[ind] < qtdOccurs[ind]) { indOccurs[ind] = indOccurs[ind] + 1; i = seqGrp[ind]; } else { indOccurs[ind] = 1; ind = ind - 1; if (ind >= 0) { if (indOccurs[ind] < qtdOccurs[ind]) { indOccurs[ind] = indOccurs[ind] + 1; i = seqGrp[ind]; } } } } } String[] columnNamesString = new String[campos.size()]; columnNamesString = campos.toArray(columnNamesString); tableStringModel = new DefaultTableModel(new Object[][] {}, // TITULOS DAS SUAS COLUNAS columnNamesString) { private static final long serialVersionUID = 1L; @Override public boolean isCellEditable(int r, int c) { return false; } }; tableString.setModel(tableStringModel); for (i = 0; i < columnNamesString.length; i++) { int teste = columnNamesString[i].length(); tableString.getColumnModel().getColumn(i).setPreferredWidth(teste * 8); } tableString.getTableHeader().setReorderingAllowed(false); tableString.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrTableString.setViewportView(tableString); }
From source file:gdt.jgui.entity.query.JQueryPanel.java
private void showHeader() { try {/*w w w . j a v a 2 s . co m*/ Entigrator entigrator = console.getEntigrator(entihome$); Sack query = entigrator.getEntityAtKey(entityKey$); if (!query.existsElement("header.item")) { query.createElement("header.item"); query.putElementItem("header.item", new Core("name", entityKey$, "number")); query.putElementItem("header.item", new Core("type", LABEL_KEY, "label")); } if (!query.existsElement("header.element")) { query.createElement("header.element"); query.putElementItem("header.element", new Core("0", entityKey$, "none")); query.putElementItem("header.element", new Core("1", LABEL_KEY, "property")); } Core[] ca = query.elementGet("header.item"); ArrayList<String> sl = new ArrayList<String>(); int i = 0; for (Core c : ca) if (c.value != null) { sl.add(c.value); } Collections.sort(sl, new ItemComparator()); Core element; for (String s : sl) { // System.out.println("JQueryPanel.showHeader:item="+s); for (Core c : ca) { if (s.equals(c.value)) { element = query.getElementItem("header.element", c.name); // System.out.println("JQueryPanel.showHeader:order="+i); element.type = String.valueOf(i++); query.putElementItem("header.element", element); break; } } } entigrator.save(query); DefaultTableModel model = new DefaultTableModel(null, sl.toArray(new String[0])); table.setModel(model); table.getTableHeader().setDefaultRenderer(new SimpleHeaderRenderer()); table.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { int col = table.columnAtPoint(e.getPoint()); String col$ = String.valueOf(col); String itemName$ = table.getColumnName(col); // System.out.println("Column index=" + col+" item="+ itemName$); String element$ = null; String field$ = null; Entigrator entigrator = console.getEntigrator(entihome$); Sack query = entigrator.getEntityAtKey(entityKey$); Core[] ca = query.elementGet("header.element"); String headerKey$ = null; // System.out.println("JQueryPanel:header listener:item name="+itemName$); for (Core c : ca) if (col$.equals(c.type)) { element$ = c.value; headerKey$ = c.name; break; } Core item = query.getElementItem("header.item", headerKey$); // System.out.println("JQueryPanel:header listener:element=" +element$ + " item=" + itemName$+" field="+field$); setSelection(elementComboBox, element$); setSelection(itemNameComboBox, item.value); setSelection(itemNameFieldComboBox, item.type); } catch (Exception ee) { Logger.getLogger(JQueryPanel.class.getName()).severe(ee.toString()); } } }); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
/** * table;// ww w . ja v a 2s . co m * * @param list */ private void updateTableData(final List<TableColumn> list) { TaskHelper.runInNonEDT(new Callable<Void>() { @Override public Void call() throws Exception { Vector<Vector<Object>> v = TableHelper2.transform1(list); Vector<Object> v2 = new Vector<Object>(); // final DefaultTableColumnModel dtcm = new // DefaultTableColumnModel(); // ["??", ""] String[][] heads = new String[][] { { "", null }, // 0 { "", null }, // 1 { "??", null }, // 2 { "??", CellEditorType.String.name() }, // 3 { "?", CellEditorType.Number.name() }, // 4 { "??", null } // 5 }; for (int i = 0; i < heads.length; i++) { String[] tmp = heads[i]; // javax.swing.table.TableColumn h = new // javax.swing.table.TableColumn(i); // h.setHeaderValue(tmp[0]); // dtcm.addColumn(h); v2.add(tmp[0]); } final DefaultTableModel dtm = new DefaultTableModel(v, v2) { private static final long serialVersionUID = 1L; /** * ?;???; */ public Class<?> getColumnClass(int col) { // //?? if (col == 4) return Integer.class; Object value = getValueAt(0, col); if (value != null) return value.getClass(); else return super.getClass(); } public boolean isCellEditable(int row, int column) { if (column == 3 || column == 4 /* || column == 5 */) return true; return false; } }; EventQueue.invokeLater(new Runnable() { public void run() { tableColumnTable.setModel(dtm); } }); return null; } }); }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
/** * table;//from w ww . j av a2 s . co m * modify by 2016618 * ?"??", ???, ?, json; * @param list */ private void updateListData(final List<ListColumn> list) { TaskHelper.runInNonEDT(new Callable<Void>() { public Void call() throws Exception { String[] heads = { "", // 0 "??", // 1 "??", // 2 // "??", // "?", // 3 "?", // 4 "??", }; Vector<String> v = new Vector<String>(); for (String h : heads) { v.add(h); } Vector<Vector<Object>> vc = new Vector<Vector<Object>>(); for (ListColumn lc : list) { Vector<Object> t = new Vector<Object>(); t.add(Boolean.valueOf(lc.isPrimary())); t.add(lc.getColumnName()); t.add(lc.getColumnAlias()); // String ta = lc.getTableAlias(); // if(StringUtils.isNotBlank(ta)){ // t.add(ta); // }else{ // t.add("t1"); // } if (lc.getSeq() == null) { if (lc.isPrimary()) t.add(IConsant.DEF_MIN_SEQ); else t.add(IConsant.DEF_MAX_SEQ); } else { t.add(lc.getSeq()); } t.add(lc.getOrder()); t.add(lc.getColumnCommon()); vc.add(t); } final DefaultTableModel dtm = new DefaultTableModel(vc, v) { /* * (non-Javadoc) * * @see * javax.swing.table.AbstractTableModel#getColumnClass(int) */ @Override public Class<?> getColumnClass(int columnIndex) { if (columnIndex == 3 || columnIndex == 4) return Integer.class; Object value = getValueAt(0, columnIndex); if (value != null) return value.getClass(); else return super.getClass(); } public boolean isCellEditable(int row, int column) { if (column == 0 || column == 3 || column == 4) return true; return false; } }; EventQueue.invokeLater(new Runnable() { @Override public void run() { listColumnTable.setModel(dtm); } }); return null; } }); }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private JTable getJHotestAddressTable() { if (jHotestAddressTable == null) { DefaultTableModel jHotestAddressTableModel = new DefaultTableModel(new String[][] {}, new String[] { "Address", "Hit count" }); jHotestAddressTable = new JTable(); jHotestAddressTable.setModel(jHotestAddressTableModel); }//from w w w .jav a 2 s . c o m return jHotestAddressTable; }
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 v a2 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; }
From source file:userinterface.DoctorWorkArea.DiagnosePatientJPanel.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: Employee patient = (Employee) patientCombo5.getSelectedItem(); String[] columnNames = { "Patient Name", "Patient ID", "Doctor Name", "Age", "Allergies", "Special Needs", "Calorie Intake", "Protien Intake", "Amino Acid" }; String[][] data = {//from w w w. j a va 2 s. co m { patient.getName(), Integer.toString(patient.getId()), patient.getMedicalRecord().getDoctorName(), Integer.toString(patient.getAge()), patient.getMedicalRecord().getAllergies(), patient.getMedicalRecord().getSpecialNeeds(), patient.getMedicalRecord().getCalorieIntake(), patient.getMedicalRecord().getProtienIntake(), patient.getMedicalRecord().getAminoAcid() }, }; tableModel = new DefaultTableModel(data, columnNames); SimpleReport(); }