Forum Stats

  • 3,851,383 Users
  • 2,263,969 Discussions
  • 7,904,691 Comments

Discussions

AWT vs. Swing

843807
843807 Member Posts: 46,582
edited Oct 2, 2002 12:56AM in Java Applet Development
I'm assuming there must be some advantages to AWT over Swing or AWT would no longer be used. What are these advantages? Why would someone use AWT as opposed to Swing?
Thanks

Comments

  • 843807
    843807 Member Posts: 46,582
    Should be:
    * older JRE backward compatibility
    * simple/light applications not deserving a nice GUI (low deployment cost)
    * best choice to introduce Java GUI to beginners
  • 843807
    843807 Member Posts: 46,582
    The most important thing is that without AWT, Swing could not exist.

    Look at the inheritance hierarchy. Swing components all subclass from AWT. AWT provides the plumbing and struts and braces and skeleton on top of which Swing is implemented.

    - David
  • 843807
    843807 Member Posts: 46,582
    Should be:
    * older JRE backward compatibility
    - most ms ie versions have jre 1.1, which has awt support, but not swing. a fair percentage of those users will not upgrade, owing to ignorance/inertia/sheer bloody-mindedness. i prefer an applet that will just run (if you have java 1.1+).
    * simple/light applications not deserving a nice GUI
    i would rather say "not requiring a flexible GUI". i'm developing a green-screen emulator, which is all custom gui components anyway. why inherit from swing, if i'm going to subclass everything anyway, and don't kneed all the swing extras ?
    (low deployment cost)
    * best choice to introduce Java GUI to beginners
    down side of AWT vs swing
    - less flexibility (you lose the whole motif side)
    - potentially slower
    AWT uses native os (windows) components for each object. this can be a real resource/speed hog. a panel with 50 native input fields takes a noticeable time to create in AWT.

    what i have ended up creating is a very thin wrapper around the AWT. the main change is that i have a lightweight textfield which descends from label, to avoid using windows input fields, which are not what i want (too large, wrong borders, etc). textarea ditto (limit input to maxrows/maxcols etc). this adds a few kb to the code, but keeps me 1.1 compatible.

    btw, if you are going to use awt for compatibility reasons, then you should probably restrict yourself to 1.1 classes/methods.

    Adrian
This discussion has been closed.