About Heavy Weight Component

U

udhayakumar

Hi,

I want to ask something about heavy weight and light weight component.
Actually what i understood is heavy weight component will use peer class and
native methods.And light weight component they wont use Peer class.(Is it
mean that it wont use native lib...?)

Suppose i want to display button in Linux ... Button Class will
call ButtonPeer Class which in turn will call native method.
Conside that it is using GTK Libraries... So in native using
gtk_button_new it will create the Button.

I understood when i am using JButton it wont call ButtonPeer class...
But Without using native library how the button will be created...
I think in this place only i misunderstood something...
Can anyone explain the flow of JButton...?????

Regards
Udhaya
 
M

Michael Borgwardt

udhayakumar said:
I understood when i am using JButton it wont call ButtonPeer class...
But Without using native library how the button will be created...
I think in this place only i misunderstood something...
Can anyone explain the flow of JButton...?????

A leightweight component exists only in Java, which means that it needs
a heavyweight native-based component (such as java.awt.Window) to be
painted on.

Basically, in swing you use heavyweight components for windows only,
and everything else is painted on them in pure Java by the Swing
framework.
 
S

stas

Hi,

I want to ask something about heavy weight and light weight component.
Actually what i understood is heavy weight component will use peer class and
native methods.And light weight component they wont use Peer class.(Is it
mean that it wont use native lib...?)

Suppose i want to display button in Linux ... Button Class will
call ButtonPeer Class which in turn will call native method.
Conside that it is using GTK Libraries... So in native using
gtk_button_new it will create the Button.

I understood when i am using JButton it wont call ButtonPeer class...
But Without using native library how the button will be created...
I think in this place only i misunderstood something...
Can anyone explain the flow of JButton...?????

Regards

When rendering lightweight components, the Java toolkit just draws the
component on the screen without resorting to any peer. It then tracks
the events generated by the user of this GUI component to understand
how the component should behave and redraws it every time it should
change its shapre, position, color, etc.

For example, talking about JButton, the JFC toolkit rendering system
just draws lines and points on the screen in such a way that it would
appear to you as if the real button was there. It then checks whether
your mouse pointer enters the area at which the JButton is drawn, and
if you click it, for instance, it redraws this area to make an
impression as if the button was pressed down, and so on.
 
M

Michael Borgwardt

stas said:
For example, talking about JButton, the JFC toolkit rendering system
just draws lines and points on the screen in such a way that it would
appear to you as if the real button was there. It then checks whether
your mouse pointer enters the area at which the JButton is drawn, and
if you click it, for instance, it redraws this area to make an
impression as if the button was pressed down, and so on.

Which is, of course, exactly the same thing that happens with heavyweight
components, only in that case it's the native GUI framework that does it.
 
J

Jim Cochrane

Which is, of course, exactly the same thing that happens with heavyweight
components, only in that case it's the native GUI framework that does it.

Pardon my interruption and my ignorance, but is the reason for using the
lightweight component that it gives better performance than the heavyweight
component?
 
M

Michael Borgwardt

Jim said:
Pardon my interruption and my ignorance, but is the reason for using the
lightweight component that it gives better performance than the heavyweight
component?

I'm not sure whether there is a significant performance difference.

The main reason is compatibility - heavyweight components are implemented
differently on different operating systems and there are often subtle
differences in behaviour. Another reason is that heavyweight components
are always opaque whereas leightweight components can be partially or
completely transparent.
 
J

Jim Cochrane

I'm not sure whether there is a significant performance difference.

The main reason is compatibility - heavyweight components are implemented
differently on different operating systems and there are often subtle
differences in behaviour. Another reason is that heavyweight components
are always opaque whereas leightweight components can be partially or
completely transparent.

Thanks.
 
T

Thomas G. Marshall

Michael Borgwardt coughed up:
A leightweight component exists only in Java, which means that it
needs a heavyweight native-based component (such as java.awt.Window)
to be painted on.

Basically, in swing you use heavyweight components for windows only,
and everything else is painted on them in pure Java by the Swing
framework.

More or less. You know this, but the JFC hierarchy sits on the
java.awt.Container. So /everything/ in swing is a java.awt.Component
descendent as well. There are peers for these classes, but you're right in
that the /true/ need by swing for the awt at that point is mostly just the
frame and window.
 
T

Thomas G. Marshall

Michael Borgwardt coughed up:
I'm not sure whether there is a significant performance difference.

The main reason is compatibility - heavyweight components are
implemented differently on different operating systems and there are
often subtle differences in behaviour

Any of us with circa 1996 java 1.0 battle scars on us know that one for
sure.

And not so subtle. In peer land, the Z-order on mac's was opposite than on
PC's which made forced overlapping of awt components a /very/ tricky
maneuver if you wanted the GUI to look sane on both platforms.
 
U

udhayakumar

Thanks for your replies...

I have one more question regarding scrollbar...

I thoguht of implementing Scrollbar.

I am having some problems while drawing...

Please let me know steps to follow...

* - I am not able to understand Min,Max and Visible parameters...

Regards

Udhaya
 
A

Andrew Thompson

I am having some problems while drawing...

Please let me know steps to follow...

1) Find the best group for your question. (descibed here)
<http://www.physci.org/codes/javafaq.jsp#cljg>

2) Post your current code.
<http://www.physci.org/codes/sscce.jsp>

3) Ask a question.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top