user3133542
user3133542

Reputation: 1715

How to change the GridLine Width of a JTable in Java?

Like the title says, is there a simple way to change the width of the gridlines in JTable?

I found out, that there is a simple way to change the color of the showed gridlines in the Jtable but I could not find any methods to change the gridline width.

Upvotes: 1

Views: 2197

Answers (1)

Piotr Oktaba
Piotr Oktaba

Reputation: 775

One of the ways is to override the prepareRenderer(...) method of JTable class, using BorderFactory to create custom border:

JTable table = new JTable( model ) {
    public Component prepareRenderer( TableCellRenderer renderer, int row, int column) {
        JComponent jc = (JComponent)super.prepareRenderer(renderer, row, column);
        jc.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
        return jc;
    }
};

Upvotes: 2

Related Questions