Merlin's Magic: J2SE 1.4.2 offers two new designs

Source: Internet
Author: User
Tags gtk

So far, all of Merlin's magic columns are new features of the Java 1.4 version, and this article is focused on the 1.4.2 version currently being tested. Sun thinks Windows ' Classic look is obsolete and no one is using motif-at least on the user's desktop. You'll find the new look of Windows and a new appearance called GTK + in the latest version of this standard Java platform, and the new Windows look like Windows xp,gtk+ uses the normal Linux desktop when users use Windows XP operating systems.

The swing architecture provides a pluggable façade framework. For example, the framework provides a standard way to make all component fonts 8-point bold Lucida without having to change all the tuning to create a component. All you need to do is insert a new setting into the skin, like magic, where all calls automatically pick up the changes. You can even change the overall style of the GUI by setting the appearance. Previously, J2SE 1.4 provided skin designs for platform-oriented UI, such as Microsoft Windows and Motif. It also offers a cross-platform UI, called metal, specifically for the Java platform, which looks all the same regardless of what desktop the user uses.

Change the appearance design

Before we examine the latest designs, let's show you how to change the look of a Java program, as shown in table 1:

Table 1: Finding all display modes

Import java.awt.*
Import javax.swing.*
public class start extends JFrame {
Public start () {
Set Defaultcloseoperation (Exit_on_close);
Container C = Getcontentpane ();
JButton button = new JButton ("Hello");
C.add (button, borderlayout.center);
SetSize (100, 50);
Show ();
}
public static void Main (string[] args) {
try {
Uimanager.setlookandfeel (
Uimanager.getcrossplatfor Mlookandfeelclassname ());
//uimanager.getsystemlookandfeelclassname ());
} catch (Exception e) {
}
new Start ();
}
}

The Uimanager Setlookandfeel () call allows you to enter a class name that is fully standardized in the new design. You no longer have to worry about which class name applies to the cross-platform metal UI (Javax.swing.plaf.metal.MetalLookAndFeel), you only need to use Getcrossplatformlookandfeelclassname () method to ask the system for a name. On the other hand, Getsystemlookandfeelclassname () returns the UI class name dedicated to the user's desktop. If the user runs the program on a Windows device, he will get the Windows UI through the Com.sun.java.swing.plaf.windows.WindowsLookAndFeel class. On UNIX devices, the MOTIF/CDE interface or Com.sun.java.swing.plaf.motif.MotifLookAndFeel class is returned. J2SE 1.4.2 provides a new GTK + appearance, but does not return a system appearance class as a UNIX machine. This situation will be improved in the J2SE 1.5 version. Figure 1 shows the output appearance of the start program when running on a Windows 2000 device:

Figure 1: Cross platform UI

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.