public method

I have a JFrame that fires up a JDialog thus:

my JDialog is: class myDialog extends JDialog ....

MyDialog md = new MyDialog( this );

in MyDialog I want to call a method in the JFrame, called MyFrame derived by

class MyFrame extends JFrame ...

so in MyDialog's constructor:

MyDialog( JFrame frame ) {

frame.method()

}

this won't compile, says it cannot resolve frame.method(), but frame defines method as public void method()..

Can anyone help?

[512 byte] By [barrydeana] at [2007-10-1 2:02:57]
# 1

Okay, my question would be which frame exactly defines the method? javax.swing.JFrame? Or your MyFrame extends JFrame?

Because if the method is defined in JFrame, your code should work, as far as I can tell. On the other hand, if the method is defined in MyFrame, it won't. You'll have to either change the MyDialog constructor to take a MyFrame object as a parameter instead of a JFrame object, or recast the JFrame to a MyFrame in the code, such as ((MyFrame) frame).method()

. That'll work.

Sincerely,

Dylan

Dylan.Piercea at 2007-7-8 10:32:47 > top of Java-index,Desktop,Core GUI APIs...
# 2
Cheers, I changed the parameter to MyFrame.Obvious when you think about it!Thanks for the help.
barrydeana at 2007-7-8 10:32:47 > top of Java-index,Desktop,Core GUI APIs...