私は持っていjxtable
ます。それは持っていhorizontalGridLines enabled
ます。これがどのように見えるかです。
水平グリッド線を太くしたい。以下の目的の外観を参照してください。2 行目以降の行には、より太い仕切りが必要です。
グリッド線の描画は、テーブルの ui-delegate によって制御されます。干渉する方法はありません。すべてのオプションはハックです。
つまり、SwingX のハックは、ターゲット行が 2 番目の場合、レンダラーを MatteBorder で装飾する Highlighter を使用することです。
table.setShowGrid(true, false);
// apply the decoration for the second row only
HighlightPredicate pr = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
return adapter.row == 1;
}
};
int borderHeight = 5;
// adjust the rowHeight of the second row
table.setRowHeight(1, table.getRowHeight() + borderHeight);
Border border = new MatteBorder(0, 0, borderHeight, 0, table.getGridColor());
// a BorderHighlighter using the predicate and the MatteBorder
Highlighter hl = new BorderHighlighter(pr, border);
table.addHighlighter(hl);
paintComponent
JXTableでメソッドをオーバーライドできます。次の例では、2 番目の行の後に 3 ピクセルの線の太さで JTable を作成します。
JXTable table = new JXTable() {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// Actual line thickness is: thickness * 2 + 1
// Increase this as you wish.
int thickness = 1;
// Number of rows ABOVE the thick line
int rowsAbove = 2;
g.setColor(getGridColor());
int y = getRowHeight() * rowsAbove - 1;
g.fillRect(0, y - thickness, getWidth(), thickness * 2 + 1);
};
};