看板 ott
作者 ott(寶貝)
標題 AWT - Abstract Windows Toolkit
時間 2010年01月13日 Wed. PM 05:10:36


     The following diagram shows most of the the class heirarchy of the
     AWT (Abstract Windows Toolkit), which comes as part of the core
     Java language (java.awt package and sub-packages.)
     
     
[圖]

     
     The key Component class provides the base class for all the AWT
     visual components and also for the Swing components. The class
     provides a very large number of public methods - see the API
     description for Component.
     
     The container class provides for holding instances of other
     component classes. The Window subclass, for example, provides for
     the top level visible containers, Frame and Dialog, that hold
     various visible components.
     
     Containers can hold other containers. The Panel class, in
     particular, is used within a top level container to arrange its
     sub-components, which often are also panels. An elaborate GUI
     display with lots of buttons, textfields, and other components
     will employ several panels and sub-panels to arrange the visible
     atomic (non-container) components.
     
     As seen in the diagram above, the basic AWT includes several
     atomic components such as buttons, labels, and textfields. You can
     create fairly elaborate GUI displays with these tools.
     
     Lightweight Wins Over Heavyweight
     
     However, as mentioned in the introduction, there are a number of
     limitations to these components. For example, simply creating a
     subclass of Button for a custom button that displays an icon is
     not practical. Java programs before 1.2 became know for a bland,
     dull appearance and limited capabilities.
     
     The basic problem is that these components are closely tied to
     so-called peer component classes written in native code for the
     local operating system GUI. This means that Java portability
     required a lowest-common-denominator approach in which no visible
     component could provide more capability that what was available on
     all platforms. This results in very limited options in how the
     components can look and perform. These basic AWT components are
     called heavyweight because they drag along all the peer component
     coding.
     
     A far more flexible approach is to open a heavyweight top level
     class, such as a frame, and then just let Java draw all the
     visible sub-components without involving any local peer
     components. Such lightweight components are very flexible,
     especially when combined with the more powerful event handling
     structure that came with Java vers. 1.1 (event handling will be
     discussed in Chapter 7: Java)
     
     The Swing set of classes (available in the javax.swing and related
     packages) consists primarily of lightweight components. Swing
     first became available as an independent set of code that would
     work with version 1.1 and then was included in the standard Java
     distribution for version 1.2. Swing will be discussed in more
     detail in the next section.
     
     Though there are some drawbacks to Swing (see the next section),
     It is now generally recommended that everyone switch their Java
     user interface design from AWT to Swing for all serious program
     development for PC and equivalent platforms.
     
     Note: In some cases, such as when developing programs for small
     platforms, it can be necessary to remain within the older AWT
     framework. We discuss small platform programming in Chapter 24.
     See the Chapter 6: Supplements section for a brief overview of
     creating user interfaces purely within the basic AWT framework.


   http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter06/AWT.html



--
※ 來源: DISP BBS (http://disp.twbbs.org)
※ 作者: ott  來自: 118.166.4.170  時間: 2010-01-13 17:10:36
※ 看板: ott 文章推薦值: 0 目前人氣: 0 累積人氣: 122 
※ 文章分類: -computer
分享網址: 複製 已複製
guest
x)推文 r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇