Java Swing Table questions
Posted
by Dalton Conley
on Stack Overflow
See other posts from Stack Overflow
or by Dalton Conley
Published on 2010-04-22T03:59:57Z
Indexed on
2010/04/22
4:03 UTC
Read the original article
Hit count: 388
Hey guys, working on an event calendar. I'm having some trouble getting my column heads to display.. here is the code
private JTable calendarTable;
private DefaultTableModel calendarTableModel;
final private String [] days = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday",
"Saturday"};
//////////////////////////////////////////////////////////////////////
/* Setup the actual calendar table */
calendarTableModel = new DefaultTableModel() {
public boolean isCellEditable(int row, int col){
return false;
}
};
// setup columns
for(int i = 0; i < 7; i++)
calendarTableModel.addColumn(days[i]);
calendarTable = new JTable(calendarTableModel);
calendarTable.getTableHeader().setResizingAllowed(false);
calendarTable.getTableHeader().setReorderingAllowed(false);
calendarTable.setColumnSelectionAllowed(true);
calendarTable.setRowSelectionAllowed(true);
calendarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
calendarTable.setRowHeight(105);
calendarTableModel.setColumnCount(7);
calendarTableModel.setRowCount(6);
Also, Im sort of new with tables.. how can I make the rowHeight split between the max size of the table?
© Stack Overflow or respective owner