Solved

making a GUI

Posted on 1998-02-18
1
192 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

813 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

11 Experts available now in Live!

Get 1:1 Help Now