Hello everyone, i thought of this question and i would greatly appreciate some pointers on it.

I have 2 simple Java Projects which are GUI based. One writes some information to a text file. The other reads the text field and displays it on the GUI.

My question: Is it possible to link both GUI files and make them under one Java Project file? I'm using Eclipse IDE by the way.

At first i thought it would be possible by calling the constructors but both my GUI files have event handling (i need the member variables for method implementation).

I'm sorry if this question was asked and answered beforehand but i do not know the "keywords" of my problem (did tried googling but to no avail).

Well I cant understand what problem you are gonna face if you construct both apps from a same main class... could u explain how ur apps are structured and what event handling u wanna do..

My program is something like:

1st App
The user selects a file to write to, feeds some input, clicks enter.
- Enter button
- Open File

2nd App
The user selects something from a jcombobox list. I print the extra details of the selected object in a text area.

I get the feeling that i'm missing something fundamental here. It might be that i'm confusing it with the way c/c++ link files together.

Well I recommended that you combine both things within the same gui frame. Separate them into two halves and put all code together. create a separate class for handling file reading and writing and let the gui class call the methods in the file handling class.

Well so tell me if Ive understood ur problem correctly:

1st app, read user input and write to a file
2nd app., read contents of the file and display to user?

So these to apps have separate code to read and write onto the same file...
If u run them independently u will face concurrency problems coz ure accessing same file.

So I recommend u restructure your app with a single GUI class and a separate class that keeps the file open and does what u want to do...

are we talking about different applications, or about different classes extending JFrame?

there is a very, VERY, big difference there.


Yes, you got the problem right.

When you said combining them both under the same GUI frame, does that mean the GUI interface will display both applications under the same window?

I was thinking something along like:
- a main menu GUI with 2 buttons: (main calling should be from here)
- write to file
- read from file
Both these applications will have a "back" button to go back to the main menu GUI.

I'm sorry but i do not understand the difference. =/

what you describe sounds (to me) like
1 -> application
containing several -> JFrames

so ... how do you contact one class from within another? that is basicly what you want.
well, you call the constructor of the class (which in this case extends JFrame) and in that constructor, you also set that class to visible (setVisible(true))

and, you can pass information between the two JFrames, by using setters and getters, or by passing parameters to the constructor

Three letters: M V C

Thats the way to go IMO too... JCherril is great!

Thanks for all the help guys. I implemented some dummy programs following stultuske's suggestion and it worked.

However, i'll have to admit that i have yet to fully understand the linking concept.