How to install another Look & Feel for JTable?

Is it possible to set different L&F for a 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 crashes or exceptions, but JTable anyway.

 NimbusLookAndFeel nb = new NimbusLookAndFeel(); jTable1.putClientProperty("Windows.Overrides",nb.getDefaults()); jTable1.putClientProperty("Windows.Overrides.InheritDefaults",false); 
+4
source share
3 answers

You can reference the URL below for all default values ​​for the nimbus user interface.

http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html

Go to the "Table" section and use all your default values ​​for the user interface in your application. This should do the trick for you.

+1
source

If you want to apply Nimbus L & F to a button, you just need to figure out which class is responsible for displaying the Nimbus buttons. The process is the same as if you wanted to apply your own custom L&F, where you set your own user interface on the button.

+1
source

One trick you can do is create a dummy application that uses the look of Nimbus, create a JTable and do something like

 System.out.println (myTable.getUI ().getClass ().getName ()); 

At this point, you will find out which UI object is used to render the JTable when using Nimbus LAF. You can use this class name when calling setUI (TableUI) on a JTable :

 myTable.setUI (new ui_manager_class_name ()); 

As others have said, this is hardly recommended. LAFs are usually intended to be used as a whole, and not as part of 2-3 LAFs. Another way out would be to use MultiLookAndFeel , but I never used it, so I'm not sure that it meets your needs, you should read the appropriate tutorial if you want to use it correctly.

0
source

Source: https://habr.com/ru/post/1385698/


All Articles