Wednesday, 15 January 2014

java - Trouble importing both JButton and JFrame with MouseListeners -



java - Trouble importing both JButton and JFrame with MouseListeners -

i'm making paint program, needs implement both mousemotionlistener , mouselistener. needs javax.swing.jframe , javax.swing.jbutton.

if import either jframe or jbutton themselves, there no compile error (besides buttons/frames won't understood). however, if import both, error in dual implementing of mouselistener , mousemotionlistener.

the error received is:

mypaint not abstract , not override abstract method mouseexited(java.awt.event.mouseevent) in java.awt.event.mouselistener

importing javax.swing.*; not solve problem, , @ loss.

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 code necessary

mypaint not abstract , not override abstract method mouseexited(java.awt.event.mouseevent) in java.awt.event.mouselistener

this means code declares implementation of interface - yet not actually implement methods defined in interface. rid of error, define method!

java swing compiler-errors mouselistener mousemotionlistener

No comments:

Post a Comment