Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:55+00:00 2026-05-23T09:04:55+00:00

I am trying to convert a working simple Java application to an applet. The

  • 0

I am trying to convert a working simple Java application to an applet. The application consists of a main.java and a gooey.java

Main.java

package hellow_convert;
import javax.swing.JApplet;
public class main extends JApplet {
public static void main(String[] args) {
gooey gui = new gooey();    
}
public void init() 
{ 
gooey gui = new gooey();        
} 
public void stop() {}
}

gooey.java

package hellow_convert;
import javax.swing.*;
import java.util.*;
import java.awt.*;
public class gooey {    
public  JFrame f = new JFrame();
private JPanel pnlNorth = new JPanel(); 
private JButton btnNorth = new JButton("North");
private JMenuBar mb = new JMenuBar(); // MenuBar
private JMenu mnuFile = new JMenu("File"); // File Entry on Menu bar
private JMenuItem mnuItemAbout = new JMenuItem("About"); // About Entry
public gooey(){
f.setJMenuBar(mb);
mb.add(mnuFile);       
mb.add(mnuHelp);
pnlNorth.add(btnNorth);
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(pnlNorth, BorderLayout.NORTH);
f.setBounds(100, 100, 200, 100);
}
}

It looks like this.
Applet
I just cant seem to make it run as an applet. When I run it in debug, an applet window opens, and then, the JFrame window pops up (just as in the application). As an application, it runs as expected, but how do I get controls into the Applet window?
I’m new to this. Any help is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:04:56+00:00Added an answer on May 23, 2026 at 9:04 am

    Well, JApplet is a Swing container itself and thus you’d have to use the applet’s content pane in your class gooey, instead of always using a JFrame (which is a desktop window and wouldn’t not work with an applet).

    Try and pass either the JApplet or the JFrame to the gooey() constructor, instead of creating the JFrame in that class.

    Edit: your constructor might look like this:

    public gooey(RootPaneContainer c){
      c.getRootPane().setJMenuBar(mb);
      mb.add(mnuFile);       
      mb.add(mnuHelp);
      pnlNorth.add(btnNorth);
      c.getContentPane().setLayout(new BorderLayout());
      c.getContentPane().add(pnlNorth, BorderLayout.NORTH);      
    

    }

    Then call it like:

    JFrame f = new JFrame(...);
    new gooey(f);
    

    or

    JApplet a = new JApplet(...);        
    new gooey(a);
    

    you could also do this in your main class, since it is already an applet instance

    new gooey(this);
    

    The setBounds(...) should only be called when dealing with a JFrame.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert an ASP.NET website into a web application project. The
I'm working on a Java web application in which files will be stored in
I'm trying to convert a simple url (below) in to a blog-style url, but
I am trying to convert my custom simple auth system in my rails app
Working with Sitecore and Linq extensions. I am trying to convert to from an
I am trying to convert my WPF application into a WPF UserControl. In the
I'm trying to make a simple picture thumbnail application. I've searched the web and
I've been trying to convert SVG images to PNG using C#, without having to
I'm trying to convert old QuickTime framework code to the 64-bit Cocoa-based QTKit on
I'm trying to convert some code that worked great in VB, but I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.