如果Swing有更多的功能来设计一个表单。那么java中AWT有什么用呢?

发布于 2024-08-23 13:42:38 字数 164 浏览 2 评论 0原文

在java中,Swing比AWT组件有更多的功能。 例如, 在AWT中, 文本区域 ta; 按钮 btn;

但在 Swing 中它是一样的,

JTextArea ta; JButton btn;

但摆动组件的外观不错。 那么AWT还需要什么呢。有什么实用的功能吗?

In java, Swing has more features than the AWT components.
For example,
In AWT,
TextArea ta;
Button btn;

But its same in Swing as,

JTextArea ta;
JButton btn;

But swing component has good in look.
Then what's the need of AWT. Is there any useful feature?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

耳根太软 2024-08-30 13:42:38

Swing 和 AWT 都提供用户界面组件,但 Swing 是构建在 AWT 之上的。它提供了AWT中所没有的更丰富的工具,如图标、工具提示等。此外,Swing 旨在便于移植,而 AWT(理论上)将更匹配系统的外观和感觉。

大多数为您提供 GUI 构建功能(NetBeans 等)的 IDE 都会使用 Swing 组件来实现。 AWT 很有用,因为它提供了构建 Swing 的基础。

更多详情请参见此处

Swing and AWT both provide user interface components, however Swing is built on top of AWT. It provides richer tools like icons, tool tips, etc. which are not available in AWT. Also, Swing is meant to be portable, while AWT (in theory) will match more of the system's look and feel.

Most IDEs that give you GUI building features (NetBeans, etc) will do so using Swing components. AWT is useful since it provides the foundation on which Swing is built.

More details here.

吲‖鸣 2024-08-30 13:42:38

如果您想要更真实的 O/S 保真度并且可以接受小部件支持的最低公分母,则 AWT 非常有用。

它对于构建您自己的轻量级 GUI(假设是游戏引擎)也非常有用。例如,我们需要一个可以在 JME PP 1.0 中的手持设备以及台式机和瘦客户端上运行的 GUI 系统,其中我们只需要一些基本组件,但开销确实很小,因此我构建了一个在 AWT 中运行的 GUI 工具包控制板。效果非常好。

AWT is useful if you want truer O/S fidelity and can accept a lowest-common-denominator for widget support.

It's also immensely useful for building your own light-weight GUI on (suppose, for a game engine). For example, we needed a GUI system which would run on handhelds in JME PP 1.0 as well as desktops and thin clients, where we needed only a few basic components, but really minimal overhead, so I built a GUI toolkit which runs within an AWT Panel. It worked out really well.

二货你真萌 2024-08-30 13:42:38

AWT 是 Java 中可用的 GUI 包,随后出现了 Swing,它构建在 AWT 之上,试图使跨平台的东西看起来更好、更一致。问题是,他们俩看起来都很糟糕。不幸的是,我在我的项目中一直使用 AWT,因为它是一个 Windows Mobile 项目,而我们的 VM 仅支持 AWT。

如果您想要一个实际上看起来不错的 Java GUI(比 Swing 或 AWT 更好),那么您需要查看 IBM 的 SWT。

AWT was the GUI package available in Java, then along came Swing, which was built on top of AWT in an attempt to make things look nicer and consistent across platforms. The problem is, they both look terrible. I am stuck with AWT in my project unfortunately, because it is a Windows Mobile project and our VM only supports AWT.

If you want a java GUI that actually looks nice (well nicer than Swing or AWT) then you want to check out SWT from IBM.

春花秋月 2024-08-30 13:42:38

AWT 是 Java UI 的第一次尝试,后来 Swing 提供了更好的替代方案,因为它们使用“轻量”组件(组件自己绘制 UI,而不是依赖本机代码),并且这些轻量组件比 AWT 更加灵活和可维护。

AWT 仍然拥有作为 Swing 和 OS 接口的底层“技术”的地位(毕竟 JComponent 继承了 java.awt.Container),因此,它在 UI 的底层占有一席之地。例如,半透明、形状等内容都放在 AWT 包中,并由 Swing 组件使用。

新的平台 UI 功能将在以下版本中添加到 Java 中,其中许多功能将添加到 java.awt 中。包裹。

AWT was the first try on UI for Java, later Swing provided a better alternative because they use "light" components ( the component draw the UI them selves instead of relaying on native code ) and those light components were way lot flexible and maintainable then AWT.

AWT still has it's place as the underlying "technology" that interface Swing and the OS ( JComponent inherits java.awt.Container after all) , so, its place in the low level of UI. For instance, things like translucency, shapes etc. are placed in AWT package and they are used by Swing components.

New platform UI features will be added to Java in the following releases and many of them will be added to the java.awt. package.

轻拂→两袖风尘 2024-08-30 13:42:38

AWT 仍然常用于小程序!大多数 Web 浏览器都支持 AWT 类,因此 AWT 小程序可以在没有 Java 插件的情况下运行。然而,Swing 小程序需要 Java 插件。较旧的 JVM 不支持 Swing。

AWT 稍快一些,因为它使用本机操作系统对等组件,而 Swing 在位级别绘制所有自己的组件。 Swing 组件的外观和行为可能与其本机对应组件完全相同。然而,AWT 应用程序看起来像本机应用程序,因此在不同平台上看起来会有所不同。相比之下,Swing 应用程序在所有平台上看起来都一样(尽管这可以通过代码更改)。

AWT is still commonly used for applets! Most web browsers support AWT classes, so AWT applets can run without the Java plugin. Swing applets, however, require the Java plugin. Swing is not supported by older JVMs.

AWT is slighter faster because it uses native OS peer components, whereas Swing draws all its own components at the bit level. Swing components may not look and behave exactly like their native counterparts. AWT applications, however, will look like native apps and so will look different on different platforms. In contrast, Swing apps will look the same on all platforms (although this can be changed with code).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文