Java Interview Nineth Day

Source: Internet
Author: User

Graphical interface:

Layout Manager:

CardLayout: Card layout, panel overlay, can only see one, the first addition will be displayed, can be flipped

Two methods of construction:

CardLayout ()

Create a new card layout with a gap size of 0.

CardLayout (int hgap, int vgap)

Creates a new card layout with the specified horizontal and vertical gaps.

Common methods:

Previous (Container parent)

Flips to the previous card in the specified container.

Show (Container parent, String name)

Flips to a component with the specified name that has been added to this layout

Next (Container parent)

Flips to the next card in the specified container.

First (Container parent)

Flips to the first card of the container.

Last (Container parent)

Flips to the last card of the container.

GridBagLayout: Enhanced grid Layout, where components can be laid out across rows across columns.

Construction Method:

GridBagLayout ()

Create a Grid package layout manager.

Attention:

The specific implementation of the layout manager requires the use of the Gridbagconstraints class to set the component with the properties of the Gridbagconstraints class, and to view the API documentation.

Menu items:

JMenuBar: The implementation of the menu bar, adding the JMenu object to the menu bar to construct the menu

Construction Method:

JMenuBar ()

Creates a new menu bar.

JMenu: The implementation of the menu is a pop-up window that contains JMenuItem

Construction Method:

JMenu (String s)

Constructs a new jmenu, using the provided string as its text.

JMenuItem: The implementation of an item in a menu, where a menu item is essentially a button in the list

Construction Method:

JMenuItem (String text)

Creates a jmenuitem with the specified text.

AWT Event Model:

Three elements of the event model:

Event Source (Object): The creator of the event.

Event (EventObject): Describes what is going on.

Event Listener (EventListener): handler for Event

Relationship:

Events are only related to event sources and are not related to event snooping

An event source can register multiple event listeners.

An event listener can be registered in multiple event sources.

An event source can register multiple event listeners for the same class of events.

Event handling mechanism: delegate-type processing mechanism (is a loose coupling)

The component itself generates an event object, but it is not necessarily responsible for handling it, but rather it is given to a listener to handle

To implement the listening process:

A. Implement the monitoring interface implements Xxxxlistener

B. Overriding method Actionperformed (ActionEvent e)

C. Register Monitor Addxxxxlistener (ActionListener l)

Adapter: A class that overrides a method in all interfaces

In the java.awt.event package, there will be some adapters, that is, the corresponding Xxxxlistener, replaced by Xxxxadapter is the adapter.

In AWT, anonymous internal classes are often used to inherit the adapter for monitoring.

Java Interview Nineth Day

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.