Reputation: 2199
1.how to set Width JTable Cell fit to Width Value?
2.how to create JTable beauty?
Upvotes: 1
Views: 1806
Reputation: 36
1) You can use following method to calculate an expected column cell width ragarding its content
FontMetrics metrics = table.getFontMetrics(table.getFont());
int width = metrics.stringWidth(strCellContent);
Upvotes: 1
Reputation: 1043
1) You need set width to TableColumn e.g.
TableColumn col = table.getColumnModel().getColumn(vColIndex);
int width = 100;
col.setPreferredWidth(width);
2) You need to specifies Renderers for cells, table ...
Upvotes: 1