JTable t; t.getColumn(id).setWidth(0);
JTable t; t.getColumn(new Integer(position)).setWidth(0);
class MyModel extends AbstractTableModel { int nbCols= 0; Vector v= new Vector(); public MyModel(ResultSet rs, int except) { int nbCols= rs.getMetaData().getColumnCount(); this.nbCols= nbCols - 1; while(rs.next()) { Vector ligne= new Vector(); int j= 0; for(int i= 0; i < nbCols; i++) if( i != except ) ligne.addElement(rs.getString(i)); v.addElement(ligne); } } public int getColumnCount() { return nbCols; } public int getRowCount() { return v.size(); } public Object getValueAt(int row, int col) { return ((Vector)v.elementAt(row)).elementAt(col); } }
int colonneARendreInvisible; ResultSet rs; JTable t= new JTable(new MyModel(rs, colonneARendreInvisible));
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionclass MyModel extends AbstractTableModel { int nbCols= 0; Vector v= new Vector(); Vector cachee= new Vector(); public MyModel(ResultSet rs, int except) { int nbCols= rs.getMetaData().getColumnCount(); this.nbCols= nbCols - 1; while(rs.next()) { Vector ligne= new Vector(); int j= 0; for(int i= 0; i < nbCols; i++) if( i == except ) cachee.addElement(rs.getString(i)); else ligne.addElement(rs.getString(i)); v.addElement(ligne); } } public String getCache(int row) { return cachee.elementAt(row).toString(); } public void setCachee(int row, String val) { cachee.setElementAt(val, row); } public int getColumnCount() { return nbCols; } public int getRowCount() { return v.size(); } public Object getValueAt(int row, int col) { return ((Vector)v.elementAt(row)).elementAt(col); } }
class MyModel extends AbstractTableModel { int nbCols= 0; Vector v= new Vector(); Vector cachee= new Vector(); public MyModel(ResultSet rs, int except) { int nbCols= rs.getMetaData().getColumnCount(); this.nbCols= nbCols - 1; while(rs.next()) { Vector ligne= new Vector(); int j= 0; for(int i= 0; i < nbCols; i++) if( i == except ) cachee.addElement(rs.getString(i)); else ligne.addElement(rs.getString(i)); v.addElement(ligne); } } public String getCache(int row) { return cachee.elementAt(row).toString(); } public void setCachee(int row, String val) { cachee.setElementAt(val, row); } public int getColumnCount() { return nbCols; } public int getRowCount() { return v.size(); } public Object getValueAt(int row, int col) { return ((Vector)v.elementAt(row)).elementAt(col); } }