This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: AWT
Jeff has it right: "heavyweight" means there's a window being used in
the native system, "lightweight" means the window is entirely virtual
and exists only in the mind of the X client. Motif does have a handful
of lightweight components (they're called gadgets), but did not end up
finding the lightweight model very promising. Evidently, neither did Tk,
Qt, or Gtk+, since they're all happily heavyweight.
Lightweight toolkits had their day in the early days of Motif, when
workstations were slower, memory was more expensive, and the X server
was full of bloated data structures. Starting up an X client with a few
dozen or hundred components brought the X server thrashing to its knees.
As Jeff notes, it now takes much more effort to do that.
As for additional network costs, let me give you a f'rinstance:
Say you've got a text field in the middle of your GUI for which you want
a different mouse cursor than the rest of the GUI: the mouse becomes a
text cursor when it enters and a default cursor when it leaves.
How does a heavyweight toolkit do it? It associates a cursor with the
window and the X server takes care of everything.
How does a lightweight toolkit do it? It has to track all mouse movement
in the application. When the mouse enters the appropriate area, it sends
a cursor change event. When it leaves, it sends another cursor change
event. Lots of additional protocol - mouse events and cursor requests -
and the work the client has to do to track it all. That's work the X
server could be doing (as it does in the heavyweight case) in native
code that has benefitted from years of tuning.
Nathan
Per Bothner wrote:
> I don't see how lightweight vs heavyweight necessarily makes much
> difference the balance of work between the client/server nor in
> the network traffic.
Jeff Sturm wrote:
>
> Per Bothner wrote:
> > In the context of Java toolkits, my understanding is that "lightweight"
> > means that the Java toolkit does most of the drawing, rather than
> > delegating it to an lower-level toolkit (such as Motif or the Windows
> > API). "Heavyweight" means that the widget uses "native" widgets -
> > i.e. it delegates drawing to some lower-level toolkit. But the
> > lower-level toolkit still has to invoke a lot of low-level drawing
> > operations. The X protocol does not provide "widgets"; they are
> > a pure library thing. (There is an implementation issue how many
> > X server windows a toolkit uses, sometimes referred to the gadget
> > vs widget distinction, which a gadget is a logical widget that
> > does not correspond to an actual window the server knows about.
> > But that is again not inherently a propery of lightweight vs
> > heavyweight toolkits.)
>
> Actually I think it is... "lightweight" widgets in AWT are those that
> extends Component or Container. "Heavyweight" widgets extend Panel or
> Canvas, or one of the other native widgets. The chief characteristic of
> heavyweight widgets in the AWT is the native window associated with
> them, not whether the widget code is implemented in native code or Java.
>
> I haven't seen any real performance degradation with heavyweight AWT
> components until a container has hundreds or thousands of heavyweight
> components... for some reason, both Win32 and Motif widgets seem to
> choke when they reach some critical mass. I observed this back in the
> good ol' 1.0 days when I was laying out large arrays of Button widgets
> for a certain project.
>
>
> --
> Jeff Sturm
> jsturm@sigma6.com
- Follow-Ups:
- Re: AWT
- From: Per Bothner <per@bothner.com>
- References:
- license question
- From: Paul Matthew Reilly <paul@pajato.com>
- AWT
- From: Lincoln Spiteri <lincoln.spiteri@st.com>
- Re: AWT
- From: "Thomas Reilly" <treilly@allaire.com>
- Re: AWT
- From: Nathan Meyers <nmeyers@teleport.com>
- Re: AWT
- From: Per Bothner <per@bothner.com>
- Re: AWT
- From: Jeff Sturm <jsturm@sigma6.com>