in the beggining , a long long time ago when java was created, the people in sun decided they wont "reinvent the wheel" and decided to use the exsisting platform tools to create the GUI. the java code would simply access the "button gui" for example in whatever platform it was running and create that button. the result was that it worked perfectly BUT they had to reduce the gui (the graphics) to the lowest , most common graphics, in order to be compatible with all the platforms. later, in the next versions, they decided to do everything themselves and they created their own components (widgets) using java code alone. this allowed for far more complex graphics with many more cool things that will be identical on all platforms (unlike before when there were diffrences in the graphics because each platform draws buttons diffrently). it is much better, nicer and cool but a little more slow than the native code. the awt components are called heavier components because they rely on the native code and the swing ones are called light components. the only rule is not mix the two.
Joined: Jul 05, 2001
Thanks Roy. But can you explain me more about the the way AWT code works. i.e. Where does it get native code for creating lets say button. If I am not wrong then, in swings the Java code is going to take care of creating components and it does not use the native code. waiting for your comments and reply. Thanks again.
Roy Ben Ami
Joined: Jan 13, 2002
im not too sure of the specifics :roll: but you can check the source code for the Button class for example in the src.jar file included with all JDK. i guess , they just access the current platform they run in and use its componenets (like in windows, it uses the WIN32 API to create it). sorry i cant provide more information, maybe someone else can.