I have a big Swing project. Is there any tool that convert the Swing application jar file into an applet?
If the original project creates a JFrame, you could simply get the JFrame's contentPane via
Container contentPane = myFrame.getContentPane();
And then add it the JApplet's as its contentPane, but you would lose menus and such.
For e.g.,
public class MyApplet extends JApplet {
@Override
public void init() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JFrame myFrame = new MyFrame("Frame");
Container contentPane = myFrame.getContentPane();
setContentPane(contentPane);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
Better to have most of your GUI classes geared to create JPanels from the get go so you don't run into this limitation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With