在我的计划,我希望用户:如何避免嵌套的ActionListeners?
- 拾取/打开数据库(如Access)对自己
- 从表中选择一个表从数据库
- 选择列(S)
在我的代码,我有一个类,做这样的事情:
mntmOpenDatabase.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//open the database
//display tables as buttons
tableButton.addActionListener(new ActionListener() { // select a table
public void actionPerformed(ActionEvent e) {
//display the columns of the table selected as buttons
colButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {// add to the list of columns to be exported }
这导致了一个非常大的代码块。有没有更干净,更简单的方法来做到这一点?
[如何使用操作(HTTP://文档。 oracle.com/javase/tutorial/uiswing/misc/action.html) – MadProgrammer