我正在做一个 java+swing+miglayout 项目,我们确定了从 JPanel 和 JFrame 继承的图形类的类设计,这里是骨架:
class GammaFrame extends JFrame {
private JPanel __pane__ = null;
public static GammaFrame open(...) {
_instance = GammaFrame()
__pane__ = _instance.getContentPane();
__pane__.setLayout(new MigLayout(...));
_instance.__init__()
# do logic job if any
return _instance;
}
public static void main(String argv[]) {
GammaFrame.open();
}
}
class GammaPanel extends JPanel {
public static GammaPanel create(...) {
_instance = GammaPanel()
_instance.setLayout(new MigLayout(...));
_instance.__init__()
# do logic job if any
return _instance;
}
public static void main(String argv[]) {
JPanel panel = GammaPanel.create()
JFrame frame = new JFrame()
frame.getContentPane().add(panel)
#
# more settings here
#
frame.setVisible(true)
}
}
这种设计可能有什么缺陷?