Board index » jbuilder » communication between classes

communication between classes


2004-01-21 06:53:42 AM
jbuilder3
Hi,
I try to establich communication between 2 classes: a frame class and a
helper class.
The helper class need some informations of the frame and the frame needs to
knwo its helper (well how else can it call the helper? :-)
But if I try to compile I get an error in the frame, because the helper
isn't yet compiled. I cannot solve this with first compiling the helper,
because it imports the frame - the definition is needed :-( (never had this
problem using smalltak....).
I think the solution must be simple... Here is the code:
SkillFrame.java:
package skills;
// diverse imports...
public class SkillFrame extends JFrame {
//...
skillJDBCOperations myOperations;
//...
//Den Frame konstruieren
public SkillFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Initialisierung der Komponenten
private void jbInit() throws Exception { // ja es ist Jbuilder!
// ...
myOperations = new skillJDBCOperations(this); // <- erzeugt den
Fehler *
//...
}
// diverse weitere Methoden...
}
-----------
skillJDBCOperations.java
package skills;
import java.awt.Frame;
import skills.SkillFrame;
/**
* Hier stehen dann mal alle Methoden, die direkt JDBC etc. nutzen um
auf
* die Skill-DB zuzugreifen.
*/
public class skillJDBCOperations {
Frame mySkillFrame;
public skillJDBCOperations() {
}
public skillJDBCOperations skillJDBCOperations() {
return this;
}
public skillJDBCOperations skillJDBCOperations(Frame aFrame) {
mySkillFrame = aFrame;
return this;
}
public static void main(String[] args) {
skillJDBCOperations skillJDBCOperations1 = new
skillJDBCOperations();
}
public void transferKeys() {
}
}
----------
*: die COmpilermeldung für die Klasse SkillFrame:
"SkillFrame.java": Fehler #: 300 : Konstruktor
skillJDBCOperations(skills.SkillFrame) nicht gefunden in Klasse
skills.skillJDBCOperations in Zeile 208, Spalte 23
How can I solve this, so that both classes know each other?
Thanx,
Ralph
 
 

Re:communication between classes

On 1/20/2004 at 5:53:42 PM, Ralph Steins wrote:
Quote
But if I try to compile I get an error in the frame, because the
helper isn't yet compiled. I cannot solve this with first compiling
the helper, because it imports the frame - the definition is needed
[snip]
Quote
*: die COmpilermeldung für die Klasse SkillFrame:
"SkillFrame.java": Fehler #: 300 : Konstruktor
skillJDBCOperations(skills.SkillFrame) nicht gefunden in Klasse
skills.skillJDBCOperations in Zeile 208, Spalte 23
How can I solve this, so that both classes know each other?
I do not speak German, but even I can guess what "Konstruktor" means.
It does not look to me as if the problem is with compilation order as
you describe. Java handles this just fine.
The error message seems to indicate that it is looking for a
constructor with a single argument of type "skills.SkillFrame", which
is not defined in the code you posted.
Look at the following code:
public skillJDBCOperations() {
}
public skillJDBCOperations skillJDBCOperations() {
return this;
}
public skillJDBCOperations skillJDBCOperations(Frame aFrame) {
mySkillFrame = aFrame;
return this;
}
The first declaration is a no-argument constructor and the other two
are *method* declarations, not *constructors*. Constructor
declarations do not have a type and cannot return a value. You
probably want to change this to:
public skillJDBCOperations() {
}
public skillJDBCOperations(Frame aFrame) {
mySkillFrame = aFrame;
}
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html