tags:

views:

48

answers:

2

Hi, As we know AWT classes uses native OS libraries for creating GUIs but Swing uses Java library itself for creating the GUI.Can anyone please give me an example of the Windows OS library corresponds to a AWT GUI ?

Thx

+1  A: 

In theory it may depend on jvm implementation. But in windows it use WinAPI probably.

Roman
Could you point specifically which API for which AWT component ?
JavaUser
@JavaUser: no. What will happen when you know that?
Roman
@JavaUser: I remember from Feynmann's interview "There is a great difference between *knowing the name* of something and *knowing something* ". Think about it.
Roman
@Roman No, it is defined by the Native peer for a particular platform... the peers are supposed to be JVM neutral by design... it is Code->pcode->JVM->JNI->Native Peer->to OS GUI...
Wintermute
@Wintermute: what is 'Native Peer'? google knows nothing about it.
Roman
@Roman Basically it code specifically written for a for a given platform to allow the AWT, and hence Swing as well to be able to "render" a given GUI feature. "Native Peer" was what Sun originally called this. The "Peer" was bound to Java via the JNI (Java Native Interface) There are non GUI types of Peers too. One thing the AWT Peers try to do, is look the same across platforms, so they as far as I know, do not use much or any of Windows MFC/etc. type of classes. If you want to understand this more fundamentally read about XView and Motif in the Wiki
Wintermute
Except from the Wiki http://en.wikipedia.org/wiki/Swing_(Java) "Since early versions of Java, a portion of the Abstract Window Toolkit (AWT) has provided platform-independent APIs for user interface components. In AWT, each component is rendered and controlled by a native peer component specific to the underlying windowing system.By contrast, Swing components are often described as lightweight because they do not require allocation of native resources in the operating system's windowing toolkit. The AWT components are referred to as heavyweight components."
Wintermute
A: 

The short answer is the MFC (Microsoft Foundation Classes) which all of Windows widgets are based on.

If you recall the great MS and Java Lawsuit the reason MS "Split" with how Java was developing was the MFC--at that point, Sun was considering a "JFC" which more or less later became Swing. they didn't want to re-invent something they already have. regardless, Swing is based on AWT which is heavily based on Motif/X which if I remember right is also what MS based their MFC on... It not the jvm that determines how a particular Java Swing/AWT element--like a button, but the Native Peer for that platform, which is bound to Java via the JNI....

Wintermute