"Look" refers to the appearance of GUI widgets (more formally, JComponents) and "feel" refers to the way the widgets behave.SecurityFocus is designed to facilitate discussion on computer security related topics, create computer security awareness, and to provide the Internet's largest and most comprehensive database of computer security knowledge and resources to the public.a lot of sites (free) have ICON sets, and Mac Aqua is a popular icon set, the actual Mac ones I believe are copyright. Under Windows, SWING should use the native ones, and under Linux/Mac/ect, it would try to emulate them./rebates/welcomeurlhttps3a2f2fSwing Architecture Overview). It would be much more simple for the Java developers to adopt Windows as the default platform for the look and feel of the widgets. Aqua has one of the largest sets of defaults for spacing and fonts of any platform.The architecture of Swing is designed so that you may change the "look and feel" (L&F) of your application's GUI (seeMac Java Aqua Look And Feel For Windows. Perhaps the best reason to start with Aqua is its sheer number of default components. That said, its often easiest for GUI programmers to begin with the Mac OS X Aqua interface rather than the standard Metal look and feel.
![]() Java Aqua Look And Feel For Windows Code To SetThe GTK+, Motif, and Windows L&Fs are provided by Sun and shipped with the Java SDK and JRE, although they are not part of the Java API.Apple provides its own JVM which includes their proprietary L&F.In summary, when you use the SystemLookAndFeel, this is what you will see: PlatformYou don't see the System L&F in the API. For Windows, the System L&F is "Windows," which mimics the L&F of the particular Windows OS that is running—classic Windows, XP, or Vista. The System L&F is determined at runtime, where the application asks the system to return the name of the appropriate L&F.Synth—the basis for creating your own look and feel with an XML file.Multiplexing— a way to have the UI methods delegate to a number of different look and feel implementations at the same time.For Linux and Solaris, the System L&Fs are "GTK+" if GTK+ 2.2 or later is installed, "Motif" otherwise. It is part of the Java API ( javax.swing.plaf.metal) and is the default that will be used if you do nothing in your code to set a different L&F.SystemLookAndFeel—here, the application uses the L&F that is native to the system it is running on. This is a way of creating a handicapped-accessible look and feel.Javax.swing.plaf.synth—an easily configured L&F using XML files (discussed in the next section of this lesson)You aren't limited to the L&Fs supplied with the Java platform. It can be used to augment the behavior of a particular look and feel, for example with a L&F that provides audio cues on top of the Windows look and feel. The "Basic" L&F is not used without being extended.In the API you will see four L&F packages:Javax.swing.plaf.basic—basic UI Delegates to be extended when creating a custom L&FJavax.swing.plaf.metal—the Java L&F, also known as the CrossPlatform L&F ("Metal" was the Sun project name for this L&F) The current default "theme" (discussed below) for this L&F is "Ocean, so this is often referred to as the Ocean L&F.Javax.swing.plaf.multi—a multiplexing look and feel that allows the UI methods to delegate to a number of look and feel implementations at the same time. The Motif and Windows L&Fs are each built by extending the UI delegate classes in javax.swing.plaf.basic (a custom L&F can be built by doing the same thing). This commonality is defined in the Basic look and feel in the API ( javax.swing.plaf.basic). Like the Java (Metal) L&F, the Motif L&F will run on any platform.All of Sun's L&Fs have a great deal of commonality. Microsoft auto update for mac riskyIf no L&F has yet been specified, the default L&F for the JRE is loaded. This can happen inadvertently when a static field references a Swing class, which causes the L&F to be loaded. Otherwise you run the risk of initializing the Java L&F regardless of what L&F you've requested. For example:Note: If you are going to set the L&F, you should do it as the very first step in your application. External L&Fs are usually provided in one or more JAR files that you add to your program's class path at runtime. For example, the bold code in the following snippet makes the program use the cross-platform Java L&F:Swing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeelHow the UI Manager Chooses the Look and FeelHere are the look-and-feel determination steps that occur when the UI manager needs to set a L&F: It then uses that UI delegate object to implement all of its drawing and event handling.To programmatically specify a L&F, use the UIManager.setLookAndFeel() method with the fully qualified name of the appropriate subclass of LookAndFeel as its argument. For example, each JLabel constructor queries the UI manager for the UI delegate object appropriate for the label. Whenever a Swing component is created,the component asks the UI manager for the UI delegate that implements the component's L&F. ![]() Then you might wish to resize each top-level container to reflect the new sizes of its contained components. To make existing components reflect the new L&F, invoke the SwingUtilities updateComponentTreeUI method once per top-level container.
0 Comments
Leave a Reply. |
AuthorValorie ArchivesCategories |