I have two classes:

(1) Class A, which extends JApplet, implements Runnable + some Listener stuff
(2) Class B, which has a main method and is not an applet

My question is, how do I create class A with class B's main method? Is this even possible?

What I'm doing right now (and this may be totally wrong because I'm still an amateur) is the following:

public class classB
{
    static classA applet;

    public static void main(String[] args){
        //misc.

        applet = new classA();
        applet.init();
    }
    //misc.
}

The problem is, the applet isn't showing up.

Using some System.out.println() lines, I'm pretty sure of the following:

  1. If I don't call the applet's init() method, that method isn't executed.
  2. The applet's paint() method is not executed.

Any idea what's going on?

Edit: By the way, the applet functions properly when I launch it manually/without classB.

Nevermind, figured it out.

I had to make a JFrame and then add the applet to the frame, then make the frame visible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.