AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Merging two programs into one

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
JNU
Guest





PostPosted: Wed Sep 03, 2003 3:15 pm    Post subject: Merging two programs into one Reply with quote



I am a Java newbie. I have written two separate programs - one
provides a gui with buttons and a textbox and the other does some
communication with hardware.

What I would like to do is to merge them somehow so that when a button
is clicked on the gui the communication part runs.

How can this be done?
Back to top
support
Guest





PostPosted: Wed Sep 03, 2003 4:15 pm    Post subject: Re: Merging two programs into one Reply with quote



You don't need to merge them.

Providing your communication Class has methods that are accessible to the
GUI class (they are either public or package visibility and the comms class
is in the same package as your gui class), then you can instantiate your
comms class from the GUI class and invoke the methods that you need to
perform the comms.

If this doesn't make any sense then pick up a book on Object Oriented
development and read up on OO concepts, and then this should all fall into
place.

In order to trigger invoking the methods on the comms class from your GUI
class you will need to implement some event handling. If you haven't got
this far, then check out the Java tutorial on the Sun site:

http://java.sun.com/docs/books/tutorial/uiswing/overview/event.html


--
Kevin Hooke
MindBeans Software Consulting
http://www.mindbeans.net


"JNU" <bakerycottages (AT) hotmail (DOT) com> wrote

Quote:
I am a Java newbie. I have written two separate programs - one
provides a gui with buttons and a textbox and the other does some
communication with hardware.

What I would like to do is to merge them somehow so that when a button
is clicked on the gui the communication part runs.

How can this be done?



Back to top
Andy Fish
Guest





PostPosted: Wed Sep 03, 2003 4:29 pm    Post subject: Re: Merging two programs into one Reply with quote



At the end of the day, any java application just comes down to a pile of
class files.

As long as the class files are all on the classpath, you can invoke any
class from any other.

what makes them two distinct 'programs' in your mind is probably that you
have two separate 'main' methods. As long as you factor all the logic out
from the comms part so that it isn't in the main method, you can call it
from the GUI part. You can leave the main method in which will allow you to
invoke it as a stand-alone if necessary.

as a previous reply said though, you need to have some understanding of OO
and component software to make sense of it all.

Andy

"JNU" <bakerycottages (AT) hotmail (DOT) com> wrote

Quote:
I am a Java newbie. I have written two separate programs - one
provides a gui with buttons and a textbox and the other does some
communication with hardware.

What I would like to do is to merge them somehow so that when a button
is clicked on the gui the communication part runs.

How can this be done?



Back to top
Roedy Green
Guest





PostPosted: Wed Sep 03, 2003 4:53 pm    Post subject: Re: Merging two programs into one Reply with quote

On 3 Sep 2003 08:15:10 -0700, [email]bakerycottages (AT) hotmail (DOT) com[/email] (JNU) wrote
or quoted :

Quote:
What I would like to do is to merge them somehow so that when a button
is clicked on the gui the communication part runs.

You hook up a listener on the button to call a method in the
communication part, perhaps instantiating a communication object
first.

See http://mindprod.com/jgloss/event11.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.