Introduction to Java Desktop application development

Source: Internet
Author: User
Tags require

Java is a great technology for servers, PCs, and mobile devices. Java is a very successful application to servers and mobile devices because of the cross-platform nature of Java. But Java's use of personal computer applications is different from that of servers and mobile devices, but it will change quickly, at least sooner than you think. In this article, I'll analyze how Java's application in the desktop environment will be upgraded, and then specifically describe the three main tools of the Java GUI (User graphics interface): AWT, Swing, and SWT. In the following, I will develop a complete Java desktop application.

Java and desktop side

Today, the popular desktop platform is the number of Windows, Macs, and Linux. But they are not perfect, Windows dominates the market for desktop operating systems, there are huge applications and development groups, but it is expensive and has many security vulnerabilities. Linux has a solid foundation, it is open source software, more reliable than Windows. Macs is very easy to manipulate and is not the target of hackers, but compared to Windows and Linux, Mac hardware and software options are very limited. Companies and individuals choose their operating system based on a number of factors. Low cost and high security are the preferred factors, leading some organizations to turn to Linux from the Windows system. Availability and support for legacy applications are important factors for many users, which means Windows will continue to enjoy a huge market. Mac has its own loyal users, which makes the apple still viable, the popularity of Linux on the desktop and the success of the Mac created a diversity that is what Java needs, and this diversity makes Java a pivotal place on the desktop.

Cross-platform support

Java runs on all relevant operating systems, including Windows, Macs, and Linux. For any organization, he wants to migrate existing applications from one operating system to another without making too many changes, so Java is their preferred desktop development platform. It may be easy to build with Microsoft's visual Tools. NET application, but this will enable you to be bound to the Windows platform. Many people may want to replace Windows with Linux immediately to avoid problems caused by the vulnerabilities of the micro-software operating system. One of the problems that users cannot tolerate is the huge cost of migrating from Windows to Linux. If your application is built in Java and you don't have these problems, the Java graphical user interface will look like the operating system you're using, and you don't need to make any changes. If one day there is a desktop operating system, Java is a safe bet, because it can now run on Windows and Linux, it can be speculated that it can also run in the future operating systems, these operating systems may be late or early by the Microsoft, or open source community, or other people to develop it.

A rich feature

Initially, Java had only a very limited number of features to build a graphical user interface. The idea is to use a platform-independent Java application interface to package a local graphical user interface for different operating systems, called abstract window tools. Only ordinary parts such as file fields, text areas, selection boxes, radio buttons, list boxes, and buttons are supported by AWT, and graphics and images feature support is very limited, that is to say, only enough to build a simple applet program. Recognizing the need for more advanced graphical user interface components and graphics capabilities, Sun has developed Swing,java 2d,java, image input/output, Java advanced Image (JAI) and many others. Some of these form components are now part of the Java 2 Standard Edition (J2SE), and some of the other extensions must be packaged with your application. For example, swing, Java 2D, and image input/output are all Java core APIs, along with the Java Development Toolkit (JDK) and the Java Runtime environment. Let's not forget the Java platform. If you develop server-side applications and require a rich graphical user interface, you should definitely choose Java. This allows you to move some of the server-side code to the client, and vice versa. For example, a project may begin with a web-based and graphical interface, and at some point the user may require that graphical elements not be implemented in HTML, and if you choose Java as a client application, then you can reuse the code that was used to make the server side. If you use remote calls, some classes actually implement the sharing of servers and clients. With a page server, Java Desktop applications can also communicate with other Java or non-Java applications, such as CORBA, TCP/IP, or HTTP.

Java Graphical interface Tools

Java has three main graphical interface tools: Awt,swing and SWT. Swing is the API (application interface) that builds Java graphical interface standards, and some AWT classes come from Swing Foundation. SWT is a very promising new form tool, funded by IBM. But in fact, the three complement each other and they meet different needs.

Awt

Abstract Window tool Set is a simple applet program design, it is not suitable for building a rich desktop graphics interface. But from the outset, it has at least one good idea of layout management, which is responsible for finding a place for components to be placed, which is necessary because GUI components have different dimensions in different operating systems. AWT now extends the component model and event handling mechanism (defined by the JavaBeans description), the new graphics API (called Java 2D), supports clipboard and drag operations, printing, access, and new GUI tool swing, all of which are grouped into Java base classes (JFC). Swing Swing is one of the most complex GUIs ever developed. It has a complete set of components from buttons to file fields to tables, tree and file editors. These components are not dependent on the local parts of the operating system, but are drawn with the original graphics like lines, rectangles, and text. This kind of painting represents the sense of the plug-in, it can imitate the local sense of view. Swing also has a platform-independent look called "Metal". The structure of swing is inspired by the MVC pattern, where there is an obvious separation between the visual GUI components on the screen and the model objects that support the data, and the communication between the GUI and the data layer is based on events. There were a number of errors in the original swing version and there was a problem with execution, which slowed down the rate at which it was accepted. The biggest problem with swing is that it is engaged and many people believe it is intended for desktop application development. Today, there are many commercial products based on swing development, including most Java integrated development tools, and my favorite integrated development tool is JBuilder, which is fast.

Swt

SWT is a graphical user interface tool developed by IBM for its Eclipse integrated development environment. SWT can be used outside of the eclipse environment and provides direct access to the operating system's local graphical user interface. Therefore, SWT-based Java applications have a local graphical user interface and can be integrated with other local applications and parts. If your desktop application produces an HTML report, you want to show it to the user. You can use swing to browse through simple HTML documents, but this is not an ideal solution. It is best to provide an IE or Mozilla browser engine in your application. The SWT community is now designing browser APIs that allow you to generate HTML windows based on IE or Mozilla. SWT can now run under AIX, HPUX, Linux, QNX, Solaris, and Windows. Mac OS X is also in progress

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.