(I'm not even close to being sure that this is even a valid approach to what I want to accomplish. Still, all input is welcome. What I was trying to do was create an applet that reads):
"Please pass the butter."
A quote by jack padron
-------------------------------------------
Can you think of a better quote?
Please, write it here.
(then, of course the user writes his or her quote. After that, my program would print):
Please write the author of the quote here.
(After entering the author, it would print the quote that the user wrote and the author underneath.I coded it perfectly as a regular java program that was unappletatized. Then I wanted to put it all into applet form... This is where I'm sure I messed up. My new weird Applet program [a modified version of the original non-applet program] doesn't work. (The original was all System.out.println();
not page.draw) I'm sure that it's laced with mistakes, but there is only one runtime error and it is the classic
"java.lang.NoSuchMethodError: main Exception in thread "main" "
(Here is my program)
import java.applet.Applet;
import java.awt.*;
import java.util.Scanner;
public class Quote extends Applet
{
public void paint(Graphics page)
{
String theirQuote;
String theAuthor;
Scanner scan = new Scanner(System.in);
page.drawString ("\"Please pass the butter.\"", 110, 70);
page.drawString ("A quote by jack padron", 110, 70);
page.drawString ("-------------------------------------------", 110, 70);
page.drawString ("Can you think of a better quote?", 110, 70);
page.drawString ("Please, write it here.", 110, 70);
theirQuote = scan.nextLine();
page.drawString ("Please write the author of the quote here.", 110, 70);
theAuthor = scan.nextLine();
page.drawString ("-------------------------------------------", 110, 70);
page.drawString ("Tadaaaa!!! This is the quote you entered.", 110, 70);
page.drawString ("...and the author :)", 110, 70);
page.drawString (theirQuote, 110, 70);
page.drawString (" -" + theAuthor, 110, 70);
}
}