• Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet with JFrame Problem - please help!

 
Matt Wil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to convert an application to an Applet. My problem is that I need to add a JFrame to my applet. My application used to call "window = new FrameSet();" where FrameSet was the JFrame(the window) of the application. My main class is called AdMakerApp. Is there any way to simply add this JFrame to my applet? I get the error that I cant add a window to a container. Below is what I have tried. Again, FrameSet refers to a JFrame. Thanks in advance!

package AdMakerApp;
import javax.swing.JApplet;
public class AdMakerApp extends JApplet{
static FrameSet window;

public void init() {
window = new FrameSet();
getContentPane().add(window);
}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to add it; just create it and make it visible, and you'll have a free-standing window.
If what you want is for the window's contents to appear on the browser surface, then you'll need to do a little more surgery, and pack the contents of the JFrame's contentPane into the applet's contentPane instead.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!