Java Swing is a nifty looking example of how to use Nimbus's methods

  • 2020-04-01 01:30:51
  • OfStack

A look and feel of the Java Swing interface that made its debut in Java 6 Update 10.
When Swing's venerable Metal interface look and feel was first released, its main aesthetic competition came from the Windows 95 interface. Ten years ago in the graphical user world
Under surface conditions, the Metal interface was an attractive and elegant alternative to other common interfaces of the time.
The updated Ocean theme in Java SE 5 has helped Metal become a viable option for now, but modifying the look and feel of the Swing cross-platform interface has also become imperative
.
Enter the Nimbus interface appearance for a new composite-based modern look. Nimbus provides a perfect interface for its applications.
And Nimbus USES Java 2D vector maps entirely instead of static bitmaps, so it's very small (only 56KB!). Can provide any resolution.
For compatibility reasons, Metal still USES the default Swing interface look and feel. But the updates needed to replace the look and feel of the Nimbus interface could not be simpler. Only need to add the following code in the main function, remember to add in the first place, then fill in other code:
Try {
UIManager. SetLookAndFeel (" com. Sun. Java. Swing. Plaf. Nimbus. NimbusLookAndFeel ");
} catch (Exception e) {
E.p rintStackTrace ();
}


You can also specify on the command line -dswing.defaultlaf =com.sun.java.swing.pl a f.nim to make Nimbus the default interface look and feel.
A permanent set properties of the method is to add the code: swing. Defaultlaf = com. Sun. Java swing. Plaf. Nimbus. NimbusLookAndFeel if swing. The properties of the file does not exist, you must create a.

The following figure is after the addition

< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201302/2013221151659435.jpg" >  

Below is before adding
< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201302/2013221151810437.gif" >  


Related articles: