Install eclipse ve plug-in

Source: Internet
Author: User

The basic components of a SWT application are the display interface, the shell interface, and the widgets interface ). Display manages the event loop and controls the communication between the UI thread and other threads. Shell is a window managed by the operating system Window Manager in an application. Each SWT application requires at least one display and shell instance greater than or equal to one. Figure 1: SWT applications from different perspectives Figure 1 shows SWT applications from different perspectives. The graph on the left is an inherited graph of a simplified UI object. The middle graph shows the container structure of the UI object ). The figure on the right is the UI appearance after creation. If an application uses multiple threads, each thread uses the Display object allocated to its own instance. Programmers can use the static method display. getcurent () to obtain the current active instance of the display object. Shell is used to display windows in a specific operating system. Shell can be maximized, minimized, or normalized. There are two types of shell. The third type is high-level shell, which is a sub-window of display and a main window. Class 2nd is a dialog shell, which depends on the existence of other shell windows. The shell window eventually becomes the above type, depending on the style bits passed to the shell constructor during shell creation ). The default value of a shell is dialogshell. That is to say, if no parameter is included, a dialog shell is used by default. If a display object is assigned to the parameter, the shell is a high-level shell. Properties of some widgets must be set at the beginning of creation. The properties of these widgets are the style bits mentioned above ). In the SWT class, the style bit is defined as a constant. For example, button = new button (shell ,). You can use the OR operator "|" to set multiple style bits. For example, if you want to set a button with a boundary, you need to pass SWT. Push | SWT. border as the style bit parameter. Before SWT development, set the environment to perform SWT application development. You need to add the SWT Library to the classpath and set the necessary environment variables. First, find the SWT. Jar library file in the eclipse_home/Eclipse/plugins/org. Eclipse. SWT. win32_2.1.0/WS/Win32 Directory. Note that the "org. Eclipse. SWT. win32_2.1.0" directory is related to the eclipse version. If you cannot find it, use the file search function. In the following window, choose Project> properies> javabuildpath> libraries> Add variable> eclipse Home> extend to add the SWT. jar file to the class path. Then you must compile the SWT application. However, the following exception occurs. This exception occurs because the SWT. Jar library uses the native library. You need to set the java. Library. PATH environment variable to use the native library in Java. The output of the console is as follows: Java. lang. unsatisfiedlinkerror: No swt-win32-2136 in Java. library. path at java. lang. classloader. loadlibrary (unknown source) at java. lang. runtime. loadlibrary0 (unknown source) at java. lang. system. loadlibrary (unknown source) at Org. eclipse. SWT. internal. library. loadlibrary (library. java: 108) at Org. eclipse. SWT. internal. win32. OS. (OS. java: 46) at Org. eclipse. SWT. widgets. display. interna L_new_gc (display. java: 1291) at Org. eclipse. SWT. graphics. device. init (device. java: 547) at Org. eclipse. SWT. widgets. display. init (display. java: 1316) at Org. eclipse. SWT. graphics. device. (device. java: 96) at Org. eclipse. SWT. widgets. display. (display. java: 291) at Org. eclipse. SWT. widgets. display. (display. java: 287) at com. swtdesigner. trytry. main (trytry. java: 24) exception in thread "Main" set Java as follows. library. P Ath variables: Choose run> Run...> JAVA applicaton> "project"> arguments> VM arguments. In "VM arguments", enter-djava. library. path = C:/Eclipse/plugins/org. eclipse. SWT. for win32_2.1.0/OS/Win32/x86, enter your own SWT. jar path. Tip: load the native Library: If you need to load the native library used by your application, you can use the runtime. getplatform. loadlibrary ("libraryname") method.

Related Article

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.