目录

Container

介绍 (Introduction)

Container类是AWT容器的超类。 Container对象可以包含其他AWT组件。

类声明

以下是java.awt.Container类的声明:

public class Container
   extends Component

类构造函数

SN 构造函数和描述
1

Container()

这将创建一个新的Container。

类方法

SN 方法和描述
1

Component add(Component comp)

将指定的组件追加到此容器的末尾。

2

Component add(Component comp, int index)

将指定的组件添加到给定位置的此容器中。

3

void add(Component comp, Object constraints)

将指定的组件添加到此容器的末尾。

4

void add(Component comp, Object constraints, int index)

使用指定索引处的指定约束将指定组件添加到此容器。

5

Component add(String name, Component comp)

将指定的组件添加到此容器中。

6

void addContainerListener(ContainerListener l)

添加指定的容器侦听器以从此容器接收容器事件。

7

protected void addImpl(Component comp, Object constraints, int index)

将指定的组件添加到指定索引处的此容器中。

8

void addNotify()

通过将此Container连接到本机屏幕资源,可以显示此Container。

9

void addPropertyChangeListener(PropertyChangeListener listener)

将PropertyChangeListener添加到侦听器列表。

10

void add Property Change Listener(String proper tyName, Property Change Listener listener)

将PropertyChangeListener添加到特定属性的侦听器列表中。

11

void applyComponentOrientation(ComponentOrientation o)

设置此容器的ComponentOrientation属性及其中包含的所有组件。

12

boolean areFocusTraversalKeysSet(int id)

返回是否已为此Container显式定义了给定焦点遍历操作的焦点遍历键Set。

13

int countComponents()

已过时。 从JDK version 1.1开始,由getComponentCount()取代。

14

void deliverEvent(Event e)

已过时。 从JDK 1.1版开始,由dispatchEvent(AWTEvent e)取代

15

void doLayout()

使此容器布置其组件。

16

Component findComponentAt(int x, int y)

找到包含指定位置的可见子组件。

17

Component findComponentAt(Point p)

找到包含指定点的可见子组件。

18

float getAlignmentX()

返回沿x轴的对齐方式。

19

float getAlignmentY()

返回沿y轴的对齐方式。

20

Component getComponent(int n)

获取此容器中的第n个组件。

21

Component getComponentAt(int x, int y)

找到包含x,y位置的组件。

22

Component getComponentAt(Point p)

获取包含指定点的组件。

23

int getComponentCount()

获取此面板中的组件数。

24

Component[] getComponents()

获取此容器中的所有组件。

25

int getComponentZOrder(Component comp)

返回容器内组件的z顺序索引。

26

ContainerListener[] getContainerListeners()

返回在此容器上注册的所有容器侦听器的数组。

27

Set《AWTKeyStroke》 getFocusTraversalKeys(int id)

返回此Container的给定遍历操作的焦点遍历键集。

28

FocusTraversalPolicy getFocusTraversalPolicy()

返回将管理此Container的子项的键盘遍历的焦点遍历策略,如果此Container不是焦点循环根,则返回null。

29

Insets getInsets()

确定此容器的insets,它指示容器边框的大小。

30

LayoutManager getLayout()

获取此容器的布局管理器。

31

《T extends EventListener》 T[] getListeners(Class《T》 listenerType)

返回此Container上当前注册为FooListeners的所有对象的数组。

32

Dimension getMaximumSize()

返回此容器的最大大小。

33

Dimension getMinimumSize()

返回此容器的最小大小。

34

Point getMousePosition(boolean allowChildren)

如果Container在鼠标指针下,则返回此Container的坐标空间中鼠标指针的位置,否则返回null。

35

Dimension getPreferredSize()

返回此容器的首选大小。

36

Insets insets()

已过时。 从JDK version 1.1开始,由getInsets()取代。

37

void invalidate()

使容器无效。

38

boolean isAncestorOf(Component c)

检查组件是否包含在此容器的组件层次结构中。

39

boolean isFocusCycleRoot()

返回此Container是否是焦点遍历循环的根。

40

boolean isFocusCycleRoot(Container container)

返回指定的Container是否是此Container焦点遍历循环的焦点循环根。

41

boolean isFocusTraversalPolicyProvider()

返回此容器是否提供焦点遍历策略。

42

boolean isFocusTraversalPolicySet()

返回是否已为此Container显式设置焦点遍历策略。

43

void layout()

已过时。 从JDK 1.1版开始,由doLayout()取代。

44

void list(PrintStream out, int indent)

将此容器的列表打印到指定的输出流。

45

void list(PrintWriter out, int indent)

从指定的缩进开始将列表打印到指定的打印编写器。

46

Component locate(int x, int y)

已过时。 从JDK version 1.1开始,由getComponentAt(int,int)取代。

47

Dimension minimumSize()

已过时。 从JDK 1.1版开始,由getMinimumSize()取代。

48

void paint(Graphics g)

涂抹容器。

49

void paintComponents(Graphics g)

绘制此容器中的每个组件。

50

protected String paramString()

返回表示此Container状态的字符串。

51

Dimension preferredSize()

已过时。 从JDK version 1.1开始,由getPreferredSize()取代。

52

void print(Graphics g)

打印容器。

53

void printComponents(Graphics g)

打印此容器中的每个组件。

54

protected void processContainerEvent(ContainerEvent e)

处理在此容器上发生的容器事件,方法是将它们分派给任何已注册的ContainerListener对象。

55

protected void processEvent(AWTEvent e)

处理此容器上的事件。

56

void remove(Component comp)

从此容器中删除指定的组件。

57

void remove(int index)

从此容器中删除由index指定的组件。

58

void removeAll()

从此容器中删除所有组件。

59

void removeContainerListener(ContainerListener l)

删除指定的容器侦听器,以便它不再从此容器接收容器事件。

60

void removeNotify()

通过删除与其本机屏幕资源的连接,使此Container不可显示。

61

void setComponentZOrder(Component comp, int index)

将指定的组件移动到容器中指定的z-order索引。

62

void setFocusCycleRoot(boolean focusCycleRoot)

设置此Container是否是焦点遍历循环的根。

63

void setFocusTraversalKeys(int id, Set《? extends AWTKeyStroke》 keystrokes)

为此Container的给定遍历操作设置焦点遍历键。

64

void setFocusTraversalPolicy(FocusTraversalPolicy policy)

如果此Container是焦点循环根,则设置将管理此Container的子项的键盘遍历的焦点遍历策略。

65

void setFocusTraversalPolicyProvider(boolean provider)

设置此容器是否将用于提供焦点遍历策略。

66

void setFont(Font f)

设置此容器的字体。

67

void setLayout(LayoutManager mgr)

设置此容器的布局管理器。

68

void transferFocusBackward()

将焦点转移到上一个组件,就好像此组件是焦点所有者一样。

69

void transferFocusDownCycle()

将焦点转移到一个焦点遍历循环。

70

void update(Graphics g)

更新容器。

71

void validate()

验证此容器及其所有子组件。

72

protected void validateTree()

递归地下降容器树并重新计算标记为需要的任何子树的布局(标记为无效的子树)。

方法继承

该类继承以下类中的方法:

  • java.awt.Component

  • java.lang.Object

↑回到顶部↑
WIKI教程 @2018