The purpose of Java interface design
Developers can develop rich and powerful desktop applications with graphical interfaces through Java SE. You can also design some tools to improve the efficiency of the software, to help you deal with mechanical work.
Java's graphical interface toolkit can be used for tools such as software development, management software development, general client development, Bank client software development, Eclipse plug-in development and other directions. In many well-known large-scale software, Java can be seen, such as some versions of Photoshop, mind Mapping software, Eclipse, idea development environment and so on.
Java has multiple sets of GUI toolkits, because none of them can meet all the requirements. The Java GUI toolkit contains AWT, swing and SWT, each with its own pros and cons, and developers can choose the right toolkit based on their needs and goals.
about AWT
Abstract Windows Toolkit (AWT) is the most primitive Java GUI toolkit. The main advantage of AWT is that it is a standard configuration for each Java version, including the Java implementation in an earlier web browser, and is very stable. This means that we do not need to install the toolkit separately and can use it in any Java runtime environment.
It is a very simple toolkit with limited GUI components, layout managers, and events (such as forms, text labels, buttons, menus, and so on). This is because Sun decided to use a least common denominator approach for AWT, providing only the controls that all operating systems have. Therefore, it only uses the GUI components that are defined for all Java host environments.
Since AWT relies on the host GUI's peer control (where each AWT component has a parallel host control or peer) to implement this GUI, the look and behavior of this GUI will vary on different hosts. This conflicts with Java's "write Once, run everywhere" concept, so AWT has limitations.
about Swing
Java Swing is part of Java fundation Classes (JFC), which tries to address the shortcomings of AWT. In Swing,Sun developed a carefully designed, flexible and powerful GUI toolkit. Swing is built on the AWT component base. Swing uses the AWT event model and support classes, such as Colors, Images, and Graphics. Swing components, layout managers, and events are a broader set of components than AWT provides, fully meeting a variety of development needs.
To overcome the disadvantages of different behaviors on different hosts, Swing minimizes the dependency on host controls. In fact, swing only uses peers for top-level components such as windows and frames, as if jframe,jwinodows,jdialog (not very clear, as if they are) is a control that invokes the local operating system. Most of the components ( jcomponent and its subclasses) are modeled using pure Java code. This means that swing is inherently well-ported across all hosts. Therefore, swing does not usually look like a local program. In fact, it has a lot of appearance, some simulate different host skins, and some provide a unique look.
The term that Swing uses for peer-based components is heavyweight (heavyweight), and the term used for the emulated component is lightweight (llightweight). In fact, Swing can support mixing of heavyweight and lightweight components in a GUI, such as the use of AWT and Swing controls in a jcontainer. Swing has the following advantages:
Based on MVC structure
Programmable appearance
Renderer and editor
Support for building GUI in any order
Accessibility
Support Automatic Destruction
is part of standard Java
about SWT
IBM prefers the implementation mechanism of AWT, making the SWT,SWT adopt the maximum common multiple approach. SWT is mostly used by local operating system controls, and some of the controls in Windows may not be available under Linux, for which the control is drawn in its own way. SWT uses a similar Java virtual machine, on different platforms, there are different development packages, we write Java code is the same, but different platform looks like the appearance is not the same, but the performance is very high, it is said that and C + + do the interface speed is similar:)
SWT is also based on peers, similar to AWT at this point. It overcomes the problem with the LCD that AWT faces by: It defines a set of controls that can be used to build most of the Office applications or developer tools, and can then create mock controls for the space that is not provided by a particular host, as is the case with Swing-by-host, which is similar For most modern hosts, almost all of the controls are based on local peers. This means that SWT-based GU I has both the appearance of the host and the performance of the host. This avoids most of the problems that are caused by using AWT and Swing. A particular host has some low-level feature controls, so SWT provides an expanded (usually simulated) version (usually using "C" as the first letter in the name), which can result in more consistent behavior.
In SWT, a peer is just some encapsulation program on the host space. This means that the SWT application is actually a host application that will inevitably inherit all the advantages and disadvantages of the host. This also means that SWT cannot fully achieve the goal of "write once, run everywhere"; it is more like a "write-once, test-everywhere" solution. This means that the SWT landscape is not as good as swing, but it is outstanding in creating a portable solution . SWT has the following characteristics:
GUI automatic destruction is not supported
Support for top-down GUI building only
Support for java2d is not perfect
Not part of standard Java
which GUI toolkit to use?
Swing is the most flexible and powerful GUI toolkit, so in interface development, swing is preferred and he can do most of the development work.
There is only one occasion that does not apply to swing: continue to write interfaces on programs developed using SWT, such as developing plug-ins for eclipse (because Eclipse is built on SWT). SWT is incompatible with swing , and they cannot be used in combination.
Citation: This is equivalent to asking whether a harmmer are better than a screw driver,of course, a hammer wieldded with suffic Ient force can probably drive a screw into a wall, and the butt of a screw can is used in a pinch to knock in a nail. However, a good carpenter keeps both Harmer and screw drivers in her tool box and would use the tool which is appropriate fo R the job at hand.
Personal feeling before Java interface completely no advantages, from the appearance to performance (I like swing look and feel, can change style), SWT's appearance changed the performance of the shortcomings, coupled with jface, and Eclipse of the RCP, I still prefer to use SWT.
Java Interface Design Swing (1)