Java Advanced Learning (ix) event response

Source: Internet
Author: User

In the GUI, we see how to organize a graphical interface with a graphics tree. However, such a graphical interface is static. We cannot interact with the interface to operate on it. Graphical elements of the GUI need to increase the incident response (event handling) in order to get a dynamic graphical interface.

Elements, events, listeners

We refer to a number of graphical elements in the GUI article. Some events may occur on these graphical elements, such as:

Click on the button

Drag scroll bar

Select Menu

Events in Java Use object representations, such as ActionEvent. Each event has a function of drawing objects, such as buttons, scroll bars, and menus.

The so-called interactive GUI, refers to when the above event occurs, there will be corresponding action generated, such as:

Change color

Change the contents of a window

pop-up menu

Each action is for an event. We put the action in a listener (ActionListener), and then let the listener monitor the event for (a drawing object). When an event occurs, the action in the listener occurs.

Therefore, a responsive GUI is the result of interaction between a graphical object, an event object, and a listener object. We already know how to create a drawing object. We need to add a listener to the drawing object and let the listener catch the event.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/

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.