Swing Skin Pack

Source: Internet
Author: User
Tags pack
Http://javootoo.l2fprod.com/index.html The site has a charge and open source skin package.

Code to load skin packs Here's a simple way to add a jar package, add the following code before the form loads, and the form is best to start with a thread.
protected void Startup () {
try {
Uimanager.setlookandfeel (New Napkinlookandfeel ());
Each skin bag has a ****lookandfeel class, check the document or look at the jar can be found, here to change it
catch (Unsupportedlookandfeelexception ex) {
Logger.getlogger (Testskin1view. class. GetName ()). log (Level.severe, NULL, ex);
}
Show (The new Testskin1view (this));
My environment is NetBean6.8.

The code is needless to say, look at the effect. Substance has bugs, it's not completely open source, but it's got a lot of skin.

napkin Look & Feel

Liquid Look & feel


Idw-gpl



Jtattoo
Com.jtattoo.plaf.smart.SmartLookAndFeel

Com.jtattoo.plaf.bernstein.BernsteinLookAndFeel


squareness Look and Feel
Net.beeger.squareness.SquarenessLookAndFeel

First question: How to use the Look&feel completely.

You may ask, what is called the complete use of look&feel. Here is not urgent to explain, first let everyone see a screenshot;



Do you see if the above picture has been used Look&feel? The answer is correct, but not complete, because his title bar has not changed, the full use of Look&feel after the screenshot below:



Do you think it's different? For swing veterans, this is a piece of cake, but it's more difficult for beginners, because many of the tutorials they see Using look&feel are like
Such: Uimanager.setlookandfeel (new Substanceofficeblue2007lookandfeel ());

Or so: try {
Uimanager.setlookandfeel ("Org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel");
catch (Exception e) {
System.out.println ("Substance Raven graphite failed to initialize");
}


Or I'm too much of a cook myself. Anyway, I don't know how to make the title bar change until I really learn how swing looks.
To change the title bar in fact, just one sentence is enough, that is, in the main method to add such a sentence: Jframe.setdefaultlookandfeeldecorated (true);

If you want to let JDialog also change, but also add: jdilog.setdefaultlookandfeeldecorated (TRUE);

Here is the final finished interface, using the Officeblue2007lookandfeel in substance:



The second question is how to add watermarks or backgrounds to the application.

The official document says very little, also does not have the concrete use example explanation, later downloaded the substance source code to look only then discovered how uses.

The following is my reference to the official source code written in the main method of a section of the core jframe.setdefaultlookandfeeldecorated (true);
Jdialog.setdefaultlookandfeeldecorated (TRUE);
try {
Substanceimagewatermark watermark = new Substanceimagewatermark (loginframe. Class. getResourceAsStream ("/demo/001.jpg"));
Watermark.setkind (Imagewatermarkkind.screen_center_scale);
Substanceskin skin = new Officeblue2007skin (). Withwatermark (watermark); Initialize the skin with a watermark

Uimanager.setlookandfeel (New Substanceofficeblue2007lookandfeel ());
Substancelookandfeel.setskin (skin); Set Skin

catch (Unsupportedlookandfeelexception ex) {
Logger.getlogger (Loginframe. Class. GetName ()). log (Level.severe, NULL, ex);
}


The code in the above has a code position is not changed, that is substancelookandfeel.setskin (skin);
It must be in Uimanager.setlookandfeel (New Substanceofficeblue2007lookandfeel ()); Under this sentence.
Otherwise you can't see the effect of the watermark. The following figure is a watermark and no watermark contrast (the left is a watermark, the right is not watermark):

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.