我想要在Java代码中的某个地方:

if(inAnApplet()) {
    initForApplet();
} else {
    initForApp();
}

最佳答案

public class MyApplet extends JApplet {

    boolean isapplet = true;


    public MyApplet() {
        this(true);
    }

    public MyApplet(boolean isapplet) {
        this.isapplet = isapplet;
    }

    public static final void main(String[] argv) {
        // is an app
        new MyApplet(false);
    }
}

10-08 18:37