我正在制作一个绘图程序,它需要同时实现MouseMotionListener
和MouseListener
. 它还需要javax.swing.JFrame
和javax.swing.JButton
。
如果我导入JFrame
或JButton
自己导入,则不会出现编译错误(除了按钮/框架不会被理解)。MouseListener
但是,如果我同时导入两者,我会在和的双重实施中遇到错误MouseMotionListener
。
收到的错误是:
MyPaint is not abstract and does not override abstract method
mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
导入javax.swing.*;
并不能解决问题,我很茫然。
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class MyPaint extends Canvas implements MouseListener, MouseMotionListener
{
public boolean bg;
public static JButton brushSize1 = new JButton("Size 1");
public static JButton brushSize2 = new JButton("Size 2");
public static JButton brushSize3 = new JButton("Size 3");
//all the code necessary