Solved

making a GUI

Posted on 1998-02-18
1
189 Views
Last Modified: 2010-04-16
I am trying to figure out the correct method to tie my GUI to the main program.  So far all I have is a GUI class that creates all the components.  Now I am trying to figure out the proper way to link the GUI to the main program.  I assume there is someway to create an instance of the GUI which will call methods in the class that instantiated it when an event is generated by the GUI, or something to
that effect.  Most of the examples I have seem seem to tie the GUI to the class that is using it, which to me seems like bad programming practice.  I should be able to let any class use the GUI and not require any changes to the GUI?


Most of the examples I have found seem to be very simple and just lump the functionality of the program and the GUI into a single class.

Would it be possible to give a simple example of how this is done?
0
Comment
Question by:micah
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1233138
Well, I think you are right in a sense that making a GUI and making the program functionality should be separated.  The problem is that it causes extra overhead since you must establish some sort of protocol and communication method between the GUI class and the main program.  An example of this in the Windows programming world would be OLE/COM where you can completely separate different functions and tie them together via the COM protocol.  It's very clean and portable but there is overhead in Windows for making it all work together.

As far as your system, if you really want to separate the GUI and main program, you could implement them as a client/server setup and have the two talk some protocol you define through some link.  For example, you could have the main program setup a listing Socket object and wait for incoming commands from the GUI.  The GUI would open a Socket to the main program and send/receive data based on the users input and feedback from the main program.  An advantage to this approach would be that the GUI and main wouldn't even have to run on the same computer.  The main drawback (except for added coding complexity) would be the overhead of a "network" linkup between the two processes.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now