javaswingjtablelook-and-feel

In Java I use a different LookAndFeel for just a single JComponent (and its children)


In Java I use

UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName()

to get the System Look and Feel

However, I am using a JTable and having problems on Windows with the Windows LAF and OSX with the OSX LAF, all the problems look to be solved if I just use the

UIManager.getCrossPlatformLookAndFeelClassName();

Is it possible to just have my JTable and the JScrollPane it is wrapped in use the Cross Platform Look and Feel without it affecting anything else or not?

And, if so, is this a really bad idea?

The problems I am seeing are:

Windows, Column Header rendering is almost indistinguishable from regular table cells

OSX, Cell background colour same as panel background

OSX, No grid lines between table cells.


Solution

  • The LAF of a component is determined at the time the component is created.

    So you can try something like:

    1. set temporary LAF
    2. create components and add them to the frame.
    3. restore the LAF

    And if so is this a really bad idea ?

    Not sure if there are an hidden problems.