java包awt_Java抽象窗口工具包(AWT)

本文介绍了Java AWT,它是创建GUI应用程序的基础API,包括Component类、Container、各种组件如Button、Label、TextField等。AWT利用平台原生GUI工具包,保持平台一致性但可能导致跨平台差异。虽然现在更多使用Swing,但AWT仍然是理解和开发GUI的重要部分。
摘要由CSDN通过智能技术生成

java包awt

Java AWT is an API that contains large number of classes and methods to create and manage graphical user interface ( GUI ) applications. The AWT was designed to provide a common set of tools for GUI design that could work on a variety of platforms. The tools provided by the AWT are implemented using each platform's native GUI toolkit, hence preserving the look and feel of each platform. This is an advantage of using AWT. But the disadvantage of such an approach is that GUI designed on one platform may look different when displayed on another platform that means AWT component are platform dependent.

Java AWT是一种API,其中包含大量用于创建和管理图形用户界面(GUI)应用程序的类和方法。 AWT旨在为GUI设计提供一套通用的工具,这些工具可以在多种平台上工作。 AWT提供的工具是使用每个平台的本机GUI工具包实现的,因此保留了每个平台的外观。 这是使用AWT的优势。 但是这种方法的缺点是,在一个平台上设计的GUI在另一个平台上显示时可能看起来有所不同,这意味着AWT组件依赖于平台。

AWT is the foundation upon which Swing is made i.e Swing is a improved GUI API that extends the AWT. But now a days AWT is merely used because most GUI Java programs are implemented using Swing because of its rich implementation of GUI controls and light-weighted nature.

AWT是制作Swing的基础,即Swing是改进的GUI API,它扩展了AWT。 但是现在仅使用AWT是因为大多数GUI Java程序都是使用Swing实现的,因为它具有丰富的GUI控件实现和轻量级的特性。

Java AWT层次结构 (Java AWT Hierarchy)

The hierarchy of Java AWT classes are given below, all the classes are available in java.awt package.

Java AWT类的层次结构如下所示,所有类均在java.awt包中提供。

heirarchy of component class

组件类 (Component class)

Component class is at the top of AWT hierarchy. It is an abstract class that encapsulates all the attributes of visual component. A component object is responsible for remembering the current foreground and background colors and the currently selected text font.

组件类位于AWT层次结构的顶部。 它是一个抽象类,封装了可​​视组件的所有属性。 组件对象负责记住当前的前景色和背景色以及当前选择的文本字体。

容器 (Container)

Container is a component in AWT that contains another component like button, text field, tables etc. Container is a subclass of component class. Container class keeps track of components that are added to another component.

容器是AWT中的一个组件,包含另一个组件,例如按钮,文本字段,表格等。 容器是组件类的子类。 容器类跟踪添加到另一个组件的组件。

面板 (Panel)

Panel class is a concrete subclass of Container. Panel does not contain title bar, menu bar or border. It is container that is used for holding components.

面板类是Container的一个具体子类。 面板不包含标题栏,菜单栏或边框。 它是用于容纳组件的容器。

窗类 (Window class)

Window class creates a top level window. Window does not have borders and menubar.

Window类创建一个顶层窗口。 窗口没有边框和菜单栏。

(Frame)

Frame is a subclass of Window and have resizing canvas. It is a container that contain several different components like button, title bar, textfield, label etc. In Java, most of the AWT applications are created using Frame window. Frame class has two different constructors,

框架是Window的子类,具有调整画布大小。 它是一个包含几个不同组件的容器,如按钮,标题栏,文本字段,标签等。在Java中,大多数AWT应用程序都是使用“ 框架”窗口创建的。 框架类有两个不同的构造函数,

Frame() throws HeadlessException
Frame(String title) throws HeadlessException

创建框架 (Creating a Frame)

There are two ways to create a Frame. They are,

有两种创建框架的方法。 他们是,

  1. By Instantiating Frame class

    通过实例化框架类

  2. By extending Frame class

    通过扩展框架类

通过实例化Frame类创建Frame窗口 (Creating Frame Window by Instantiating Frame class)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值