JGrid Tutorial #2

Unterstrich

#Swing

JGrid Tutorial #2

After we created a simple JGrid (see tutorial #1 we want to modify the look now. The JGrid has a lot of getter/setter to change the visualization of the grid. Read the JavaDoc for a complete overview of all properties.

Here is an example of changing colors and dimensions:

grid.setFixedCellDimension(56);
grid.setHorizonztalMargin(4);
grid.setVerticalMargin(4);
grid.setHorizontalAlignment(SwingConstants.LEFT);
grid.setBackground(Color.WHITE);
grid.setSelectionBorderColor(Color.BLUE);
grid.setSelectionBackground(Color.CYAN);
grid.setCellBackground(Color.LIGHT_GRAY);

After setting all properties the grid looks like this:

Tutorial2

You can download the sources for the tutorial here.