Perry Smith
Java Questions & Answers
Home /
Java Q & A Page 2 /
Java Q & A Archive Main Page
declare abstract?
Friday, 04-Dec-98 12:26:02
206.215.24.95 writes:
I still am having problems with this simple applet. It seems like the compiler is finding
the mouseListener now, but it doesn't know what to do with the voids. I appreciate any help.
Is there a reference for compiler error codes that offers more information and suggestions
for corrections? I hate wasting band width and I'm afraid I'm embarrassing myself by asking
elementary questions.
Also, since I have to work in the DOS shell with the JAVA compiler, is there a way to log
the compiler messages. It looks like I will be generating a lot of them and they scroll off
the window.
Thanks,
Kim
-------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ClickHere extends Applet implements MouseListener
{
String DisplayString = new String ("Click Here");
public void init () {
addMouseListener(this);
System.out.printLn("Welcome to ClickHere!");
}
public void paint(Graphics g) {
g.setColor( Color.blue );
g.drawRect( 0, 0, 150, 80 );
g.drawString( DisplayString, 50, 20 );
}
public void mouseClicked (Event evt,int x, int y) {
showStatus("Welcome to ClickHere!");
DisplayString = "Thank You";
repaint();
}
public void mouseEntered (Event evt) {}
public void mouseExited (Event evt) {}
public void mousePressed (Event evt) {}
public void mouseReleased (Event evt) {}
}
-------------------------------------------------
ClickHere.java:5: class ClickHere must be declared abstract. It does not define void
mouseReleased(java.awt.event.MouseEvent) from interface java.awt.event.MouseListener.
public class ClickHere extends Applet implements MouseListener
^
ClickHere.java:5: class ClickHere must be declared abstract. It does not define void
mouseEntered(java.awt.event.MouseEvent) from interface java.awt.event.MouseListener.
public class ClickHere extends Applet implements MouseListener
^
ClickHere.java:5: class ClickHere must be declared abstract. It does not define void
mouseExited(java.awt.event.MouseEvent) from interface java.awt.event.MouseListener.
public class ClickHere extends Applet implements MouseListener
^
ClickHere.java:11: Method pritLn(java.lang.String) not found in class java.io.PrintStream.
System.out.pritLn("Welcome to ClickHere!");
^
6 errors
Kim Spears
Response
Re: declare abstract?
Friday, 04-Dec-98 15:24:46
148.5.110.65 writes:
Kim,
Your mouse... methods must be declared exactly as they are in the interface. This is to say,
as the compiler points out, the parameters need to be of type MouseEvent, not Event.
Your last error is simply a typo. Since Java is case-sensitive you must have a lower-case 'l',
i.e. System.out.println(...);
As for your last two paragraphs, I don't know of any "reference for compiler error codes" or
how to stop the error scrolling. I have just worked from the bottom up. I have found the
error messages to be pretty good once you get used to deciphering them. Note that it did
tell you that you needed a MouseEvent type for your mouse... functions.
I was a teacher once and my wife is one so do not dispare and have patience. There are no
stupid questions, only stupid answers! :-) That's how we learn!!!
Scott_M2
Stop Compiler Message Scrolling
Tuesday, 08-Dec-98 15:02:47
152.173.228.108 writes:
You can try two things to stop compiler messages from scrolling. You asked about creating a
log, all you have to do for that is to type "javac MyClass.java > log.txt" and then you can
bring up "log.txt" and review the messages.
Alternatively, you can try "javac MyClass.java | more" [that's a "pipe" which is
Shift+backslash"] which will should cause it to stop scrolling after a screenful of info.
MikeD
Home /
Java Q & A Page 2 /
Java Q & A Archive Main Page