![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e952. Setting the Gap Size Between Cells in a JTable ComponentThe horizontal space (column margin) and vertical space (row margin) between cells can be customized. If you increase the column margin, the cell widths automatically increase by the same amount. However, if you increase the row margin, the cell heights do not automatically increase. In order to increase the cell heights, you need to callsetRowHeight() explicitly.
JTable table = new JTable(); // Add data here // Get defaults Dimension d = table.getIntercellSpacing(); // d.width == 1, d.height == 1 // Add 5 spaces to the left and right sides of a cell. // Add 2 spaces to the top and bottom sides of a cell. int gapWidth = 10; int gapHeight = 4; table.setIntercellSpacing(new Dimension(gapWidth, gapHeight)); // Increase the row height table.setRowHeight(table.getRowHeight()+gapHeight);
e950. Packing a Column of a JTable Component e951. Setting Grid Line Properties in a JTable Component
© 2002 Addison-Wesley. |