public void dbRemoveElement(int id) { lm.remove(id); dbItems.remove(id); dbItemsK.remove(id); dbItemsK2.remove(id); this.setModel(lm); }
public void dbAddElement(Object testo, Object valore, Object valore2) { lm.addElement(testo); dbItems.add(testo); dbItemsK.add(valore); dbItemsK2.add(valore2); this.setModel(lm); }
public void dbAddElement(String testo, String valore) { lm.addElement(testo); dbItems.add((Object) testo); dbItemsK.add((Object) valore); dbItemsK2.add(null); this.setModel(lm); }
public void dbClearList() { dbItems.removeAllElements(); dbItemsK.removeAllElements(); dbItemsK2.removeAllElements(); lm.clear(); this.setModel(lm); }
public boolean dbOpenList(Connection connection, String sql) { dbClearList(); this.oldSql = sql; this.oldConnection = connection; // apre il resultset da abbinare ResultSet resu = null; ResultSetMetaData meta; try { stat = connection.createStatement(); resu = stat.executeQuery(sql); meta = resu.getMetaData(); if (meta.getColumnCount() > 1) { this.contieneChiavi = true; } // righe while (resu.next()) { for (int i = 1; i <= meta.getColumnCount(); ++i) { if (i == 1) { dbItems.add((Object) resu.getString(i)); lm.addElement((Object) resu.getString(i)); } else if (i == 2) { dbItemsK.add((Object) resu.getString(i)); // debug // System.out.println("list:" + String.valueOf(i) + ":" + resu.getString(i)); } else if (i == 3) { dbItemsK2.add((Object) resu.getString(i)); } } } this.setModel(lm); // vado al primo if (dbTextAbbinato != null) { // debug // javax.swing.JOptionPane.showMessageDialog(null,this.getKey(0).toString()); dbTextAbbinato.setText(this.getKey(0).toString()); } return (true); } catch (Exception e) { javax.swing.JOptionPane.showMessageDialog(null, e.toString()); e.printStackTrace(); return (false); } finally { try { stat.close(); } catch (Exception e) { } try { resu.close(); } catch (Exception e) { } meta = null; } }
public void dbReplaceTextAt(String testo, int index) { lm.setElementAt(testo, index); this.setModel(lm); }