我正在寻找一种在Swing中清晰组织我的UI代码的方式。
假设我的UI代码按以下方式结构化:
假设我在主方法中实例化了一个MainWindow对象:
按钮的ActionEvents最佳实践是什么?这些按钮声明在SomePanel内,SomePanel又声明在MainWindow内。如何从我的main方法中监听这些ActionEvents?
非常感谢您的帮助!
假设我的UI代码按以下方式结构化:
class MainWindow extends JFrame {
// SomePanel panel is added here
}
class SomePanel extends JPanel {
// buttons, checkboxes and so on are added here
}
假设我在主方法中实例化了一个MainWindow对象:
MainWindow frame = new MainWindow("I am an App");
按钮的ActionEvents最佳实践是什么?这些按钮声明在SomePanel内,SomePanel又声明在MainWindow内。如何从我的main方法中监听这些ActionEvents?
非常感谢您的帮助!