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?
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