I've a JTable that I fill with a class that extends AbstractTableModel. The problem is that the columns are too short to display the column name. I've turned off Jtable AutoResizeMode property, but shortening still occurs. How do I solve this?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
there are two ways
1) calculate
PreferredSize
fromTableColumn
(by defalut returns JLabel), there are 3-4 correct ways how to determine displayedTextLenght in pixex
(please add plus 5-8 pixes moreover)2)
setPreferredSize
directly, e.g.TableColumn#setPreferredSize
Setting off autoresizemode only prevent the JTable's coumns to be resized. To force a particular width retrieve the table column model:
and set the desired width:
You can use the Table Column Adjuster to adjust the column widths based on the header text.
The
getColumnHeaderWidth(...)
shows how to calculate the actual width using the header text and renderer.