Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java GUi program Execution

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Thanked 0 Times in 0 Posts

    Default 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...

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default 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

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default 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
    Last edited by copeg; April 19th, 2010 at 08:53 PM.

Similar Threads

  1. Help with this java program
    By Nemphiz in forum Object Oriented Programming
    Replies: 3
    Last Post: April 13th, 2010, 03:09 AM
  2. program execution with warnings
    By prince joseph in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 28th, 2010, 03:53 PM
  3. Not Looping? (do - while) bad execution!
    By chronoz13 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 23rd, 2009, 08:51 PM
  4. How do you add GUI to this java program?
    By leyla in forum AWT / Java Swing
    Replies: 1
    Last Post: October 18th, 2009, 01:32 PM
  5. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 10:18 PM

Tags for this Thread