我的代码片段的屏幕截图
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.*;
public class GUI extends Frame implements ActionListener
{
private TextField buy = new TextField(30);
private Button appl;
public GUI(){
super("GUI");
setLayout(new FlowLayout());
setSize(400,150);
setTitle("Stock Market Exchange");
setVisible(true);
aapl = new Button("Buy AAPL share");
add(aapl);
aapl.setEnabled(true);
aapl.setBounds(35,6,112,36);
aapl.setBackground(new Color(214,217,223));
aapl.setForeground(new Color(0,0,0));
aapl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
createAAPLshare();
}
});
add(buy);
aapl.setVisible(true);
}
“公共类 GUI 扩展 Frame 实现 ActionListener” - 不断返回错误,因为 GUI 不是抽象的,并且无法覆盖 java.awt.event.ActionListener 中的 actionPerformed(java.awt.event.ActionEvent)。但我似乎无法弄清楚这个错误在哪里以及为什么会不断返回。我试图搜索各种方法来修复它,但仍然存在编译器错误。我错过了什么?
MYYA
潇潇雨雨
相关分类