|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Junior Member
Iscritto dal: Apr 2010
Messaggi: 15
|
[java] jtable: autoridimensionamento e nomi colonne
Ciao,
Ho un problema con le jTable: Come faccio ad autoridimensionare le colonne in base al contenuto? Come faccio a dare i nomi alle colonne? Questo il codice che ho usato per la creazione della tabella: Codice:
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return 8;
}
public int getRowCount() {
return list.size();
}
public Object getValueAt(int row, int col) {
return s[row][col];
}
};
JTable table = new JTable(dataModel);
JScrollPane scrollpane = new JScrollPane(table);
add(table);
table.setAutoResizeMode(5);
pack();
|
|
|
|
|
|
#2 | |
|
Junior Member
Iscritto dal: Apr 2010
Messaggi: 15
|
Quote:
con table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS); Codice:
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return 8;
}
public int getRowCount() {
return list.size();
}
public Object getValueAt(int row, int col) {
return s[row][col];
}
};
JTable table = new JTable(dataModel);
table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
JScrollPane scrollpane = new JScrollPane(table);
add(table);
pack();
}
|
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 20:08.




















