Josh
Josh

Reputation: 828

Converting an Java Application to an Applet

I am trying to convert a java application into an applet. I had a JFrame which had a 5 JPanels on it so to convert it I made the JFrame into a JPanel (mainPanel) and made the class extend JApplet.

However, I cannot update any of the panels when the mainPanel is on the applet however with exactly the same code - when the mainPanel is on a JFrame it works and the panels update.

Can anyone help?

Upvotes: 0

Views: 392

Answers (2)

Ravi Shankar Pandey
Ravi Shankar Pandey

Reputation: 1

You can convert Java Application into Java by initializing Applet in beginning and defining components in init();

Upvotes: 0

DejanLekic
DejanLekic

Reputation: 19787

Josh, converting a JFrame to JApplet is very easy.

Say you have a JFrame like this:

public class MyApp extends JFrame {
  .
  .
  public void initComponents() {
    // components initialisation here
  }
}

This class can easily become a JApplet:

public class MyApp extends JApplet {
  .
  .
  public void init() {
    // components initialisation here
  }
}

Note the difference - initComponents() became init() because Applets need the init() method.

Upvotes: 1

Related Questions