E
Eric Bresie
I'm sure this is a newbie sort of questions...so forgive me ahead of
time..
I want to work with a base Class A (which extends JFrame) which makes
a basic frame. This frame contains a number of panels where assorted
buttons, fields, etc are added to a number of panels which will be
used in all classes derrived from this class.
There is shared panel which is created to contain additional
components which will be added in the extended class.
I want a new Class B which extends class A. In class B, I want to
added elements into the shared panel defined in class A.
How is the best way to do this?
I tried having something like:
public class A extends JFrame {
JPanel contentPane ;
JPanel sharedPanel ;
JPanel fieldPanel ;
JPanel buttonPanel ;
public A() {
contentPane = (JPanel)this.getContentPane();
sharedPanel = new JPanel();
fieldPanel = new JPanel();
buttonPanel = new JPanel();
// configure Panes ...
// buttons added to buttonPanel
// fields added to fieldPanel
}
}
public class B extends A {
public B() {
// fields added to sharedPanel
sharedPanel.add( /* assorted components added here */ );
}
}
I'm using a GUI development tool, so this may be whats throwing me off
some, but when I do this similar scenario, it doesn't seem to allow me
to add the components correctly like this.
I also tried doing something like....
public class B extends A {
public B() {
this.setContentPane(sharedPanel);
this.getContentPane().add( /* assorted components added here
*/ );
}
}
Which doesn't seem to work correctly either..
How is the proper way to do this?
--
I'm kind of new to interfaces, so I'm not sure about this..
I want to have additional classes also extended from A which will have
overloaded functions...is this a case where I should define an
interface which each derrived class (like class B) would implement? I
want to have something like Class A having a defined
defaultFunction(), then class B overload this defaultFunction() but
also call the super() version of the function to ensure correct
handling of base class variables.
Eric Bresie
(e-mail address removed)
time..
I want to work with a base Class A (which extends JFrame) which makes
a basic frame. This frame contains a number of panels where assorted
buttons, fields, etc are added to a number of panels which will be
used in all classes derrived from this class.
There is shared panel which is created to contain additional
components which will be added in the extended class.
I want a new Class B which extends class A. In class B, I want to
added elements into the shared panel defined in class A.
How is the best way to do this?
I tried having something like:
public class A extends JFrame {
JPanel contentPane ;
JPanel sharedPanel ;
JPanel fieldPanel ;
JPanel buttonPanel ;
public A() {
contentPane = (JPanel)this.getContentPane();
sharedPanel = new JPanel();
fieldPanel = new JPanel();
buttonPanel = new JPanel();
// configure Panes ...
// buttons added to buttonPanel
// fields added to fieldPanel
}
}
public class B extends A {
public B() {
// fields added to sharedPanel
sharedPanel.add( /* assorted components added here */ );
}
}
I'm using a GUI development tool, so this may be whats throwing me off
some, but when I do this similar scenario, it doesn't seem to allow me
to add the components correctly like this.
I also tried doing something like....
public class B extends A {
public B() {
this.setContentPane(sharedPanel);
this.getContentPane().add( /* assorted components added here
*/ );
}
}
Which doesn't seem to work correctly either..
How is the proper way to do this?
--
I'm kind of new to interfaces, so I'm not sure about this..
I want to have additional classes also extended from A which will have
overloaded functions...is this a case where I should define an
interface which each derrived class (like class B) would implement? I
want to have something like Class A having a defined
defaultFunction(), then class B overload this defaultFunction() but
also call the super() version of the function to ensure correct
handling of base class variables.
Eric Bresie
(e-mail address removed)