Solved

making a GUI

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Understanding websocket example in spring 1 57
eclipse formatting 6 73
thymeleaf natural templating vs JSP 2 68
windows explorer path to command prompt 5 33
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 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

19 Experts available now in Live!

Get 1:1 Help Now