Graphical user interface

Source: Internet
Author: User

Two sets of components are available in the Java API to support the authoring user interface, including AWT and swing

AWT (Abstract window Toolkit), the Chinese translation of the Abstraction Windows Toolkit, is the basic tool that Java provides for creating and setting up a graphical user interface for Java. AWT is provided by the java.awt package in Java, which contains a number of classes that can be used to create platform-independent graphical user interfaces (GUIs), which are also known as components.

Swing is a development kit for developing the Java application user interface. Based on the Abstract Window Toolkit (AWT), you can use any pluggable styling for cross-platform applications. Swing developers can use Swing's rich, flexible features and modular components to create elegant user interfaces with little code. All packages in the toolkit are named by swing, such as javax.swing,javax.swing.event. Java uses the event delegate model to handle events: The event source triggers an event, but the event source itself does not handle the event, but instead delegates to the object that is interested in the event, which is called the Listener, and AWT provides Javaapplet and Java The basic components in the GUI of the user graphical interface available in application. Because Java is a platform-independent programming language, but the GUI is often dependent on a specific platform, Java uses the appropriate technology to enable AWT to provide applications independent of the Machine platform interface, This ensures that the GUI of the same program runs on a different machine with a similar appearance (not necessarily exactly the same). Java1.0 AWT (old AWT) and Java1.1 after the AWT (new AWT) There is a great difference, the new AWT overcomes the old AWT many shortcomings, in the design of a larger improvement, the use is more convenient, here mainly introduces the new AWT, However, the old AWT program can also be run in Java1.1 and later versions. Listener: ActionListenerMethod: Actionperformed Event: ActionEvent string Getactioncommand () Actioncommand is a string inside the control that identifies the state of the control. This function can take the state of the control and decide what to do. int getmodifiers () gets "When this event occurs, the user presses the key combination at the same time" long Getwhen () gets the "timestamp when this event occurred" event because: Click the button, select the content in the list box, enter in the text box, and the timer expires Listener: AdjustmentlistenerMethod: Adjustmentvaluechanged Event: AdjustmentEvent adjustable getadjustable () adjustable is an interface, and various scroll bars implement this interface. int Getadjustmenttype () Get scroll type, total unit_increment,unit_decrement,block_increment,block_decrement,track total 5 types of int GetValue () Gets the current value of the scroll slider event due to: scroll bar scrolling Listener: ItemListenerMethod: Itemstatechanged Event: ItemEvent Objedt GetItem () gets the selected element. Note that the return value is object and you should also force the type conversion. Itemselectable getitemselectable () itemselectable is an interface that represents objects that contain n selectable child elements. This method returns the object that generated this event. The main purpose of this method is that if a list box is allowed to be multi-select, then the above method is not useful, you should use this method to get the list object, and then get the multiple selected elements. int Getstatechange () Gets the state of the selection, which is the cause of the selected or deselected event: Various button clicks, list box selection Listener: FocuslistenerMethod: Focusgained, Focuslost event: FocusEvent Component getoppositecomponent () Gets the other object that participates in the focus transformation. If it is a focus-get event, the object that has the focus is returned, and if the focus loses the event, the object that gets the focus is returned. Returns a null Boolean istemporary () if the focus shifts to another application, whether the focus is a temporary transfer or a permanent transfer. Temporary transfer: Dragging a window or window into an inactive state with the mouse. Others are permanent transfers. Cause of event: Focus change of various components

Graphical user interface

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.