private void table() { table = new JTable(); table.setShowVerticalLines(false); table.setEnabled(false); model = new DefaultTableModel( new Object[][] {}, new String[] {"Bar kod", "Naziv", "Cena", "Kategorija", "Količina"}); table.setModel(model); table.setBounds(10, 110, 500, 350); Iterator<Artikal> artikli = snabdevac.getArtikli().iterator(); // Popunjavanje tabele while (artikli.hasNext()) { Artikal a = artikli.next(); String[] s = new String[] { String.valueOf(a.getBarKod()), a.getNaziv(), String.valueOf((a.getCena() - a.getPopust())), a.getKategorija(), String.valueOf(a.getKolicina()) }; model.addRow(s); } layeredPane.add(table); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBounds(10, 110, 500, 350); layeredPane.add(scrollPane); }
public void updateTable() { model = new DefaultTableModel( new Object[][] {}, new String[] {"Bar kod", "Naziv", "Cena", "Kategorija", "Količina"}); table.setModel(model); while (model.getRowCount() > 0) model.removeRow(0); Iterator<Artikal> artikli = snabdevac.getArtikli().iterator(); // Popunjavanje tabele while (artikli.hasNext()) { Artikal a = artikli.next(); String[] s = new String[] { String.valueOf(a.getBarKod()), a.getNaziv(), String.valueOf((a.getCena() - a.getPopust())), a.getKategorija(), String.valueOf(a.getKolicina()) }; model.addRow(s); } }