Swing 简明教程

SWING - Containers

容器是 SWING GUI 组件的组成部分。容器提供了放置组件的空间。AWT 中的 Container 本身就是一个组件,它提供了将组件添加到自身的特性。以下是需要考虑的部分注意事项。

Containers are an integral part of SWING GUI components. A container provides a space where a component can be located. A Container in AWT is a component itself and it provides the capability to add a component to itself. Following are certain noticable points to be considered.

  1. Sub classes of Container are called as Container. For example, JPanel, JFrame and JWindow.

  2. Container can add only a Component to itself.

  3. A default layout is present in each container which can be overridden using setLayout method.

SWING Containers

以下是使用 SWING 设计 GUI 时常用容器的列表。

Following is the list of commonly used containers while designed GUI using SWING.

Sr.No.

Container & Description

1

PanelJPanel is the simplest container. It provides space in which any other component can be placed, including other panels.

2

FrameA JFrame is a top-level window with a title and a border.

3

WindowA JWindow object is a top-level window with no borders and no menubar.