hey guys, i was wondering what the easiest way to convert a simple java jpanel app and make it useable on the web either as an applet or a popup java app.
a tutorial or link in the right direction would be much appritiated
Thanks for your help
:)
Printable View
hey guys, i was wondering what the easiest way to convert a simple java jpanel app and make it useable on the web either as an applet or a popup java app.
a tutorial or link in the right direction would be much appritiated
Thanks for your help
:)
It's easy to have a class that extends Applet and also has a main method that constructs and displays a JFrame with the same content.Another and probably better approach would be to write the code within createContents() as a class extending JPanel, and two driver classes that add this customized panel to an applet or a frame.Code:public class DualPurpose extends JApplet {
public void init() {
add(createContents());
}
public static void main(String[] args {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.add(createContents();
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
private JComponent createContents() {
JPanel panel = new JPanel();
// add components and functionality
return panel;
}
}
db
If i showed you how my code is laid out would you be able to explain it more specifically to my app. i have three classes, a driver class, a display window class(extends jframe) and a constructor with all my buttons and rectangles and ovals and stuff. i think i understand what your saying but its always been useful to have a worked example. do you have the "before" code of your applet. like the equivalent of it but as a desktop app.