Reputation: 1383
Is it possible to set different L&F to specific component (in my case JTable
) than is already used? If so, how to do it?
Edit: I wrote this piece of code according to this tutorial. Why is this code not working? No fails or exceptions, but JTable
is still the same.
NimbusLookAndFeel nb = new NimbusLookAndFeel();
jTable1.putClientProperty("Windows.Overrides",nb.getDefaults());
jTable1.putClientProperty("Windows.Overrides.InheritDefaults",false);
Upvotes: 5
Views: 3422
Reputation: 8195
One trick you could do is create a dummy application that uses the Nimbus look and feel, create a JTable
, and do something like
System.out.println (myTable.getUI ().getClass ().getName ());
At that point you will know which UI object is used to render the JTable
when using the Nimbus LAF. You can use this class name when calling setUI (TableUI)
on your JTable
:
myTable.setUI (new ui_manager_class_name ());
As others have said, this is hardly something we recommend though. LAF's are usually meant to be used as a whole package rather than a mix of 2-3 LAF's. Your other way out could be to use the MultiLookAndFeel
, but I have never used it, so I'm not sure it does fulfill your needs. You should read the associated tutorial if you want to use it correctly.
Upvotes: 1
Reputation: 268
You can refer the below URL for all UI default values for nimbus look and feel
http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html
Go to Table section and use all the those Table component specific UI default values in your application. That should do the trick for you.
Upvotes: 1
Reputation: 5386
If you would like to apply the Nimbus L&F to a button, then you simply need to figure out which class that is responsible for rendering Nimbus buttons. The process is just the same as if you want to apply your very own custom L&F, where you set your own UI class on the button.
Upvotes: 1