简体   繁体   中英

acm.graphics library - Applet starts instead

I'm trying to use the ACM library, my source code looks like this. On running it the Applet is started, but the output is still in the console within Eclipse. It is supposed the app to be started in a standalone window, not in the console. What I'm doing wrong?

import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Breakoutme extends GraphicsProgram {

    public void run() {
        println("Hi there");
    }

}

println will not produce output in Applet window. I honestly think you have no idea what you're doing. Breakout is supposed to be all graphics, why are you using println ?

You have to add a GLabel in order to do that.

GLabel hiThere = new GLabel("Hi There", 40, 40);

add(hiThere);

but you can do the same in a ConsoleProgram but instead of println() you have to use print()

将GraphicsProgram更改为ConsoleProgram,它将起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM