当前位置: 技术问答>java相关
awt和swing有何不同?
来源: 互联网 发布时间:2015-02-06
本文导语: | AWT(Abstract Window Toolkit)是早期的图形界面库,是很不成熟的东西,所以被贬为Awkward Window Toolkit,SWING是现在的图形界面库,虽然比之AWT要好多了,但还是很糟,很大,很慢 | AWT uses "heavyweight ...
|
AWT(Abstract Window Toolkit)是早期的图形界面库,是很不成熟的东西,所以被贬为Awkward Window Toolkit,SWING是现在的图形界面库,虽然比之AWT要好多了,但还是很糟,很大,很慢
|
AWT uses "heavyweight controls", meaning they have Java wrappers around native controls; also referred to as peers, is tied more directly to the OS you are using.
JFC/Swing is 100% Java, and are referred to as "lightweight controls". It inherits from AWT. Swing separates you from the GUI framework of the OS, and makes a more platform nuetral application in appearance and sizing.
JFC/Swing is 100% Java, and are referred to as "lightweight controls". It inherits from AWT. Swing separates you from the GUI framework of the OS, and makes a more platform nuetral application in appearance and sizing.
|
swing是对awt的扩展,它提供了大量的轻量构件,替代了原来awt的重量构件,方便用户更好的实现界面。但是,由于microsoft的ie对于swing的支持不够,目前使用swing制作的japplet需要用heml converter转换之后才能正常显示。
|
There are no big architectural differences, the class hierarchy is almost the same. The reason is that
Swing is built upon AWT.
The most significant difference is how the components are drawn to the screen. AWT is so called
heavyweight components and have their own viewport, which sends the output to the screen.
Swing is lightweight components and does not write itself to the screen, but redirect it to the
component it builds on. Heavyweight
components also have their own z-ordering. This is the reason why you can't combine AWT and
Swing in the same container. If you do, AWT will always be drawn on top of the Swing
components.
You can combine AWT and Swing, just don't do it in the same container (e.g. panel, groupbox, etc.)
and don't put a heavyweight
component inside a lightweight.
Another difference is that Swing is pure Java, and therefore platform independent. Swing looks
identically on all platforms, while AWT looks different on different platforms.
Swing is built upon AWT.
The most significant difference is how the components are drawn to the screen. AWT is so called
heavyweight components and have their own viewport, which sends the output to the screen.
Swing is lightweight components and does not write itself to the screen, but redirect it to the
component it builds on. Heavyweight
components also have their own z-ordering. This is the reason why you can't combine AWT and
Swing in the same container. If you do, AWT will always be drawn on top of the Swing
components.
You can combine AWT and Swing, just don't do it in the same container (e.g. panel, groupbox, etc.)
and don't put a heavyweight
component inside a lightweight.
Another difference is that Swing is pure Java, and therefore platform independent. Swing looks
identically on all platforms, while AWT looks different on different platforms.