When you dedicate a class to a specific Swing component, is it better to extenduse that particular component or build it inside and provide a link?
public class Foo extends JComponent{
}
OR
public class Foo{
public JComponent getComponent(){
}
}
EDIT
This is what I mean by initiation.
public class Foo{
private static Foo INSTANCE;
public static Foo getInstance(){
if(INSTANCE == null){
INSTANCE = new Foo();
}
}
public void createAndShowComponent(){
}
}
Inside, createAndShowComponent()I create JComponentwith all its components and their corresponding listeners without , displaying the internal components of the component just created.
source
share