java的下拉菜单监听组件重复监听设置?
我写了一个下拉菜单的监听。程序可以完美运行,每次点击完一个下拉菜单中的一个按钮后,他可以显示出我要的数据,但是点其他按钮就变成无效。得把程序窗口关了在开菜可以。怎么改可以...
我写了一个下拉菜单的监听。 程序可以完美运行,每次点击完一个下拉菜单中的一个按钮后, 他可以显示出我要的数据, 但是点其他按钮就变成无效。 得把程序窗口关了在开菜可以。 怎么改可以让我每次点一个按钮就显示一个我要的数据?而不用一直重复运行程序选择
public class DisplayMenuHandler implements ActionListener {
GUI myPlayerGUI;
public BaseballPlayerList originalList;
public BaseballPlayerList fielderList;
public BaseballPlayerList pitcherList;
public DisplayMenuHandler (GUI gui) {
myPlayerGUI = gui;
originalList = new BaseballPlayerList();
fielderList = new BaseballPlayerList();
pitcherList = new BaseballPlayerList();
}
public void actionPerformed(ActionEvent event) {
String menuName;
menuName = event.getActionCommand();
if (menuName.equals("All")){
GUI.print(myPlayerGUI, originalList); // print linked list which contain all players, call from myPlayerGUI.
}
if (menuName.equals("Fielder")){
GUI.print(myPlayerGUI, fielderList); // print all fielder
}
if(menuName.equals("Pitcher")){
GUI.print(myPlayerGUI, pitcherList); //print all pitcher
}
//actionPerformed(event);
}
} 展开
public class DisplayMenuHandler implements ActionListener {
GUI myPlayerGUI;
public BaseballPlayerList originalList;
public BaseballPlayerList fielderList;
public BaseballPlayerList pitcherList;
public DisplayMenuHandler (GUI gui) {
myPlayerGUI = gui;
originalList = new BaseballPlayerList();
fielderList = new BaseballPlayerList();
pitcherList = new BaseballPlayerList();
}
public void actionPerformed(ActionEvent event) {
String menuName;
menuName = event.getActionCommand();
if (menuName.equals("All")){
GUI.print(myPlayerGUI, originalList); // print linked list which contain all players, call from myPlayerGUI.
}
if (menuName.equals("Fielder")){
GUI.print(myPlayerGUI, fielderList); // print all fielder
}
if(menuName.equals("Pitcher")){
GUI.print(myPlayerGUI, pitcherList); //print all pitcher
}
//actionPerformed(event);
}
} 展开
1个回答
2015-05-04
展开全部
这个是事件接口吧。。。。。。。那是怎样写添加事件的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询