Swing lookAndFeel

Hi,
Please, help me to understand, how can i apply swing lookAndFeel to Dockable panes.

I have easy class



public class Test {

	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setSize(600, 600);
		DockFrontend frontend = new DockFrontend();
		SplitDockStation station = new SplitDockStation();
		frame.add(station);
		frontend.addRoot("split", station);
		ColorDockable red = new ColorDockable("Red", Color.RED);
		ColorDockable blue = new ColorDockable("Blue", Color.BLUE);
		frontend.addDockable("red", red);
		frontend.addDockable("blue", blue);
		frontend.setShowHideAction(true);
		frontend.setHideable(red, true);
		frontend.setHideable(blue, true);

		SplitDockGrid grid = new SplitDockGrid();
		grid.addDockable(0, 0, 1, 1, blue);
		grid.addDockable(0, 1, 1, 1, red);
		station.dropTree(grid.toTree());

		frame.setVisible(true);
	}
}

 

and i have javax.swing.LookAndFeel object.



javax.swing.LookAndFeel laf = getLaf();
 

How to apply LookAndFeel to my Test class?

  1. The most easy way is just to set the LaF before creating any UI components, just call UIManager.setLookAndFeel, then start the app.
  2. If you are using the Common project (I recommend doing that) you get access to the “LookAndFeelList”. You can access an object by calling the static method “getDefaultList”. The class offers methods to access all installed LaFs, and a method “setLookAndFeel” to change the current LookAndFeel. Using this method has the great advantage, that DockingFrames will call “updateUI” on a lot Components, including Dockables that are not visible at the moment.
    You can even install additional "ComponentCollector"s which then are used to update the UI of any Component you can think of.
  3. Or you call UIManager.setLookAndFeel and manually iterate through all the Components. That would be the traditional way of doing things.

And just to avoid confusion: the theming mechanism of the framework has nothing to do with LookAndFeels at all. Theming is done be calling either “DockController.setTheme”, or even better “CControl.setTheme”.

Thank you very much, you really helped me.