Advanced Synth: With the latest swing look, customizing the UI is a cinch

Source: Internet
Author: User

Introduction: This article will delve into the Synth look, which is the most recent introduction to Swing in Java 5.0. By introducing the concept of "skin" for Java UI programming, Synth enables developers to create and deploy customized skins for applications. Software engineer Michael Abernethy will take you from scratch to build a synth-looking application that gives you a full understanding of the synth concept. After reading this article, you should be able to create a professional-looking UI in a short period of time.

As Sun has always tried to "reintroduce Java Desktop", the complaints of Java UI Developers are also surfacing: it's too hard to create a fully customizable look. Not only does it take too much time, but the writing and documentation of Swing UI code is also extremely poor, often Lan Chi and poorly planned. To create a complete look, developers need to inherit 39 classes of the Metal appearance, or 60 classes that inherit Basic appearance. Who wants to rewrite the entire package to change the way the application renders its appearance? How hard it is to create a custom look with Swing, as the following facts can glimpse: In an era when many developers contribute to open source projects, the number of custom Swing available on the Internet is almost rare--a total of about 20, a handful of which are in the Sourceforge.ne On t (see Resources).

Beauty is just a superficial thing

Entering Synth,sun wants it to make the personalization process of the application look easier. Synth's goal is simple--it lets developers create new skins without having to write any code. This seems like a good solution. Programmers typically do not have outstanding artistic talent, and graphic designers are not usually Java programming experts. Synth all the description of the appearance from the code, and put it into the external XML file and image file, for the above problems provide a great satisfaction solution. This appearance, which is completely described in an external file, is called the Skin (skin).

Sun's skin concept is not an innovation. For example, Winamp has hundreds of kinds of skin, Firefox also has dozens of kinds of skin, these skins are easy to create, just change an XML file. Imagine that simply modifying an XML file can quickly and easily create an appearance for a Java application. Think again about the results-hundreds of different Swing appearances. Of course, Java UI developers have reason to cheer.

This article will delve into the Synth look and show you everything you need to know to create a complete look or skin. You'll see an application with sample skin that uses all the important concepts of Synth. Then I'll dissect the skin, and in the process of building an XML file, I'll teach you all the Synth concepts.

The last section of this article will try to answer questions from developers about Synth performance, bugs and defects, and Synth performance in time-saving terms. After reading this article, you should be willing to embrace Synth as an appearance solution and be ready to use it immediately to create your own Swing look.

Synth Foundation

Synth is a whiteboard (tabula rasa) appearance--a completely blank canvas, represented as a completely blank panel, which displays things only if the component is defined in the XML file. Once you have defined the components, it is easy to set the Synth appearance on your application, as shown in Listing 1:

Listing 1. Set Synth appearance

SynthLookAndFeel synth = new SynthLookAndFeel();
  synth.load (SynthFrame.class.getResourceAsStream("demo.xml"), SynthFrame.class);
  UIManager.setLookAndFeel(synth);

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.