【发布时间】:2017-01-30 14:26:27
【问题描述】:
我在代码中遇到了障碍。这是手头的课程。
public class StartRoom extends Room implements ActionListener {
JButton buttonTwo;
public StartRoom() {
start();
buttonOne = new JButton("Go to door.");
buttonTwo = new JButton("Look at skeleton.");
label = new JLabel("You walk into the dungeon, the room is covered with vines. There is a skeleton sitting near the northern door. What do you do?");
panelOne.add(label);
panelOne.add(buttonOne);
buttonOne.addActionListener(this);
buttonTwo.addActionListener(this);
}
class MyActionListener implements ActionListener {
@Override
public void actionPerformed(java.awt.event.ActionEvent ae) {
}
}
public static void main( String[]args ) {
new StartRoom();
}
}
它说StartRoom类型必须在第五行实现继承的抽象方法java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent),但我不知道它在问什么!
【问题讨论】:
-
必须继承ActionListener的抽象方法
actionPerformed(ActionEvent)。如果您阅读错误,我认为这很明显。如果你不理解这里的一个术语,那么你可能没有完全理解 OO。所以再读一遍 -
为什么会有这么多赞?提问者显然忘记了实现他们的接口。也许是朋友的支持?或者我只是迷信/偏执。