0

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?

kleopatra
  • 51,061
  • 28
  • 99
  • 211
Josh
  • 818
  • 2
  • 16
  • 27

2 Answers2

1

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.

DejanLekic
  • 18,787
  • 4
  • 46
  • 77
  • *"X to JApplet is very easy."* Anything involving 'to JApplet' is rarely, if ever, 'easy'. Further, applets are inherently more tricky to deploy and update. As one (of many) examples, see [Copy & Paste Not working in a *Signed* Applet](http://stackoverflow.com/questions/8513740/copy-paste-not-working-in-a-signed-applet). – Andrew Thompson Dec 15 '11 at 15:28
0

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