Java GUi program Execution
Hello Friends....
I have a very basic but yet important question which I hope you people will answer me..
I want to know how a Java GUI based program executes.As you might know how does a Visual C++ MFC program executes..The application does some initialization,then it waits in infinite loop to gets messages dispatched by Windows OS to operating System what we call Callback. So Can anyone explain me java GUI program's execution architecture.Any help or useful links will be appreciated...
Thanks..
Re: Java GUi program Execution
A lot of the actual window handling is buried inside of the AWT code (since it does require a JNI interface to make it work with the local machine). Because Java's main focus is code re-use, almost every GUI component is designed to be plug-able. Java is also designed to work on multiple platforms/OS's, so the underlying implementation of how different components work will vary from system to system. However, all you really need to know is how to handle/send events on the Java side and setting up how different components will be plugged together.
Here's a good tutorial on how to use Swing (one of the three major GUI types, the other two are AWT and SWT): Trail: Creating a GUI with JFC/Swing
Re: Java GUi program Execution
The tutorial that helloworld points to will get one started on how to create a GUI, and as already mentioned knowing how everything works behind the scenes is far from crucial to create a GUI. That being said, I believe the Swing/AWT gui works quite similarly to other GUI's, conceptually. There is a single continuous thread that deals with the GUI (called the Event Dispatch Thread), and events are 'dispatched' to this thread and dealt with in the order they are dispatched for drawing/updating the GUI (the reason a GUI will hang or freeze if one places a long computationally intensive process in a Listener interface). The EDT is a single threaded model, so if you spawn other threads it is adviseable to dispatch any updates to the GUI to the EDT. Many of the listener interfaces in AWT/Swing work similarly to the callback mechanism