Novice helps

zhaozj2021-02-12  172

// New way to the road help

Import java.applet. *; import java.awt. *; import java.awt.event. *; public class listener extends applet imports actionListener, MouseMotionListener {Int x = -1, y = -1, rubber = 0, clear = 0; color c = new color (255, 0); int CON = 3; Button Redbutton, BlueButton, Greenbutton, RubberButton, ClearButton; Public void init () {addMouseMotionListener (this); RedButton = New Button ("Red" BlueButton = New Button; GreenButton = New Button ("Green"); RubberButton = New Button; ClearButton = New Button ("Clear"; add (redbutton); add ( bluebutton); add (greenbutton); add (rubberbutton); add (clearbutton); redbutton.addActionListener (this); bluebutton.addActionListener (this); greenbutton.addActionListener (this); rubberbutton.addActionListener (this); clearbutton.addActionListener ( THIS); setsize (640, 480);} // paint method public void Paint (graphics g) {if (Rubber == 0 && Clear == 0) {G.SetColor (C); G.Filloval (x, y, con, CON);} // end of if else if (Rubber == 1 && Clear == 0) {g.clearRect (x, y, 10, 10);} else if (Rubber == 0 && Clear == 1) {g.clearRect (0, 0, getSize (). Width, getsize (). Height);}} public void mousedragged (mouseEvent E) {x = (int) E.GETX (); y = (int) E.GETY (); Repaint ();} public void mousemove (mouseEvent E) {} public void update (graphics g) {PAINT (G);} public void actionPerformed (an) {if (E.GetSource () == redbutton) {rubber = CLEAR = 0; C = New Color (255, 0, 0);} else if (E.Getsource () ==

Bluebutton) {rubber = CLEAR = 0; c = new color (0,0,255);} else if (E.GETSource () == GreenButton) {rubber = clear = 0; c = new color (0,255,0);} ELSE IF (E.GetSource () == RubberButton) {Rubber = 1; Clear = 0;} else if (E.GetSource () == ClearButton) {rubber = 0; Clear = 1; repaint ();}} //Error message

F: / school courseware /JAVA/java/listener.java:4: listener is not abstract and does not override abstract method mouseReleased (java.awt.event.MouseEvent) in java.awt.event.MouseListenerpublic class listener extends Applet implements ActionListener,

转载请注明原文地址:https://www.9cbs.com/read-7716.html

New Post(0)