Applet, Application, JFrame, JPanel confusion

I’m a bit hazy as to the true meaning of JFrame and Jpanel.
I can add a JFrame to an application, and it draws nicely directly on to the frame.
But am I supposed to make a Panel that is drawn on to, and pass the Panel to the frame?

And what about when I try to make this into an applet - I can’t add a JFrame to the Applet,
getting ‘java.lang.IllegalArgumentException: adding a window to a container’

So I can make the Jpanel and add that, but what is the function of the JFrame then?
should I make a blank JFrame receptacle in the Application to receive the JPanel,
and put all my code in JPanel?

once more with feeling to clear up the structure:
I’m trying to separate all the real code from the Applet and Application Initialization and Running.
so at the moment:

Applet -> makes JPanel -> adds JPanel
Application -> makes JFrame -> adds JFrame
this is BAD because I have cloned class, JPanel and JFrame are nearly identical ( I am testing this to figure it out as I go also )

should this be
Applet -> makes JPanel -> adds JPanel
Application -> makes JFrame -> makes -> JPanel -> addPanelToFrame -> addFrameToApplication?

I always thought the JFrame was the window.

the panel can set certain content. Like an htmlpane can display websites.

Okay, put everything in a panel and things are looking nicer…
However if user Alt+Tabs out and back everything gets really blinky…
maybe i punch in some code here, this is shooting in the dark how to handle reassembling the screen…

Oh boy this gets messy, when I make the executable jar
it loses keylisteners and mouselisteners… hmm hmm it seems
to be a bit random whether it gets Listeners in the Eclipse build also…
who steals my listeners… oivoi

public class FullScreenSlicks implements Runnable /*, FocusListener*/{
private boolean running;
GraphicsDevice device;
SlicksPanel panel;
JFrame frame;

public FullScreenSlicks() {
	
	Console.print("Create FullScreenSlicks Object");
	frame = new JFrame();
	panel = new SlicksPanel();
	running = true;
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
	
}

/**run  */
public void run(){
	try {
		
		
		device.setFullScreenWindow(frame);
		DisplayMode displayMode = device.getDisplayMode();
        
		frame.createBufferStrategy(2);
        BufferStrategy strategy = frame.getBufferStrategy();
        
        int w = displayMode.getWidth();
        int h = displayMode.getHeight();
        panel.setSize(w, h);
        
        Console.print("found screen w:"+w+", h:"+h);
        frame.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				device.setFullScreenWindow(null);
				frame.setVisible(false);
				System.exit(0);
			}
			
			public void windowActivated(WindowEvent e)
			{
				Console.print("XXXXXXXXXXXXX activated");
				device.setFullScreenWindow(frame);
			}
			public void windowDeactivated(WindowEvent e)
			{
				Console.print("deactivated");
			}
		});
        
		Graphics g = strategy.getDrawGraphics();

		frame.add(panel);
		panel.setBufferStrategy(strategy);
                    panel.setDisplayMode(displayMode);
		panel.init();
		
		while(running) {
		
			//Console.print("running");
			
			g = strategy.getDrawGraphics();
			
			panel.update(g);
			
			strategy.show();

			
            if(panel.stop) {
                running = false;
            }
            /*
            if(frame.stop) {
                running = false;
            }*/
			//Thread.sleep(50);
		}
	}
	catch(Exception e) {
		e.printStackTrace();
	}finally{//Cleanup what ever happends.
		Console.print("do we clean up?");

		device.setFullScreenWindow(null);
		frame.setVisible(false);
		System.exit(0);
	}
}


public static void main(String[] argv) {
    Console.print("main()");
    FullScreenSlicks t = new FullScreenSlicks();
    Thread th = new Thread(t);
    th.start();
    
}

whya re you worried about making a program that can be both applet and application. It isnt possible. Just make the best possible solution for one of them.