Java - AWT 090822

来源:互联网 发布:面试java虚报工作经验 编辑:程序博客网 时间:2024/05/21 06:40

[Referring to JDK 6 Documentation]

 

 

 

 

AWT Class Structure层次结构图

AWT Components Structure 组件层次结构图 

 

 

Label 标签

 

public class Label

extends Component

implements Accessible

A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.

 

 

Panel 面板

 

public class Panel

extends Container

implements Accessible

Panel is the simplest container class. A panel provides space in which an application can attach any other component, including other panels. The default layout manager for a panel is the FlowLayout layout manager.

 

public class ScrollPane

extends Container

implements Accessible

A container class which implements automatic horizontal and/or vertical scrolling for a single child component.

 

 

Button 按钮

 

public class Button

extends Component

implements Accessible

This class creates a labeled button. The application can cause some action to happen when the button is pushed.

 

 

CheckBox /多选按钮

 

public class Checkbox

extends Component

implements ItemSelectable, Accessible

A check box is a graphical component that can be in either an "on" (true) or "off" (false) state. Clicking on a check box changes its state from "on" to "off," or from "off" to "on."

 

public class CheckboxGroup

extends Object

implements Serializable

The CheckboxGroup class (Radio Button) is used to group together a set of Checkbox buttons. Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time. Pushing any button sets its state to "on" and forces any other button that is in the "on" state into the "off" state.

 

 

Pop-up Menu 弹出菜单

public class Choice

extends Component

implements ItemSelectable, Accessible

The Choice class presents a pop-up menu of choices (Pop-up menu). The current choice is displayed as the title of the menu.

 

 

Pull-down Menu下拉菜单

 

public class MenuBar

extends MenuComponent

implements MenuContainer, Accessible

The MenuBar class encapsulates the platform's concept of a menu bar bound to a frame. In order to associate the menu bar with a Frame object, call the frame's setMenuBar method.

 

public class Menu

extends MenuItem

implements MenuContainer, Accessible

A Menu object is a pull-down menu component that is deployed from a menu bar.

 

public class MenuItem

extends MenuComponent

implements Accessible

All items in a menu must belong to the class MenuItem, or one of its subclasses.

 

public class CheckboxMenuItem

extends MenuItem

implements ItemSelectable, Accessible

This class represents a check box that can be included in a menu.

 

 

List Box 列表框

public class List

extends Component

implements ItemSelectable, Accessible

The List component presents the user with a scrolling list of text items (Scrolling List). The list can be set up so that the user can choose either one item or multiple items.

 

 

Text Input 文本输入框

 

public class TextField

extends TextComponent

A TextField object is a text component that allows for the editing of a single line of text.

 

public class TextArea

extends TextComponent

A TextArea object is a multi-line region that displays text. It can be set to allow editing or to be read-only.

 

 

Dialog 对话框

 

public class Dialog

extends Window

A Dialog is a top-level window with a title and a border that is typically used to take some form of input from the user.  A dialog can be either modeless (the default) or modal. A modal dialog is one which blocks input to some other top-level windows in the application, except for any windows created with the dialog as their owner. (See AWT Modality specification for details.)

 

public class FileDialog

extends Dialog

The FileDialog class displays a dialog window from which the user can select a file. Since it is a modal dialog, when the application calls its show method to display the dialog, it blocks the rest of the application until the user has chosen a file.

 

 

 

Frame 框架组件

public class Frame

extends Window

implements MenuContainer

A Frame is a top-level window with a title and a border.

 

 

Container Components 容器组件

 

public class Container

extends Component

A generic Abstract Window Toolkit (AWT) container object is a component that can contain other AWT components.  Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container, it will be added to the end of the list (and hence to the bottom of the stacking order).

 

public class Insets

extends Object

implements Cloneable, Serializable

An Insets object is a representation of the borders of a container. It specifies the space that a container must leave at each of its edges. The space can be a border, a blank space, or a title.

 

 

Canvas Component 画布组件

 

public class Canvas

extends Component

implements Accessible

Canvas is the most basic and simplest GUI component.  Canvas A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user. The paint method must be overridden in order to perform custom graphics on the canvas. 

 

 

 

Layout Settings 版面布局

 

public class BorderLayout

extends Object

implements LayoutManager2, Serializable

BorderLayoutWindow的默认的布局管理器。BorderLayout最多只能放5个组件,要想放多个组件,要先将部分组件放在Panel中,然后再把Panel添加到BorderLayout中。如果组件小于5个,没有放置组件的地方,将被相邻的组件占用。A border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center. Each region may contain no more than one component, and is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER.

 

public class FlowLayout

extends Object

implements LayoutManager, Serializable

A flow layout arranges components in a directional flow, much like lines of text in a paragraph.

Flow layouts are typically used to arrange buttons in a panel. FlowLayoutPanel默认的布局管理器。

 

public class GridLayout

extends Object

implements LayoutManager, Serializable

The GridLayout class is a layout manager that lays out a container's components in a rectangular grid. The container is divided into equal-sized rectangles, and one component is placed in each rectangle.

 

public class CardLayout

extends Object

implements LayoutManager2, Serializable

A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards. CardLayout布局管理器能够实现将多个组件放在同一个容器区域内的交替显示,相当于多张卡片在叠一起,在任何时候都只能看到最上面的一个。

 

public class GridBagLayout

extends Object

implements LayoutManager2, Serializable

The GridBagLayout class is a flexible layout manager that aligns components vertically, horizontally or along their baseline without requiring that the components be of the same size. Each GridBagLayout object maintains a dynamic, rectangular grid of cells, with each component occupying one or more cells, called its display area.

 

 

Event 事件

 

java.awt

public interface ActiveEvent

An interface for events that know how to dispatch themselves. By implementing this interface an event can be placed upon the event queue and its dispatch() method will be called when the event is dispatched, using the EventDispatchThread.

 

java.awt.event.ActionEvent

public class ActionEvent

extends AWTEvent

A semantic event which indicates that a component-defined action occurred. This high-level event is generated by a component (such as a Button) when the component-specific action occurs (such as being pressed). The event is passed to every every ActionListener object that registered to receive such events using the component's addActionListener method.

 

java.awt.event.MouseEvent

public class MouseEvent

extends InputEvent

An event which indicates that a mouse action occurred in a component. A mouse action is considered to occur in a particular component if and only if the mouse cursor is over the unobscured part of the component's bounds when the action happens.

 

public interface ActionListener

extends EventListener

The listener interface for receiving action events. The class that is interested in processing an action event implements this interface, and the object created with that class is registered with a component, using the component's addActionListener method. When the action event occurs, that object's actionPerformed method is invoked.

 

处理发生在某组件上的Event事件的某种情况,其事件处理的通用编写步骤如下:

- 编写一个实现ActionLinstener接口的事件监听器类A

- 事件监听器类A中的用于处理该事件的方法actionPerformed中,编写处理代码;

- 调用组件的addActionLinstener方法,将类事件监听器类A创建的实例对象注册到组件上.

 

 

原创粉丝点击