First read the API doc on applets and the Tutorial about Applets
Start with a class that extends JApplet.
Move the code in main() to an init() method.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
do this
public void init()
{
write all here
}
Thats all you nothing else
Please do not forget to extend JApplet for th class
freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
but this still won't run in the applet.
Can you explain please?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
This won't run in the applet, even thought the applet is open. The code still runs in the JOption Pane
What is the code supposed to do?
What does "run" mean? Does the code execute? Does it do what you'vecoded it to do?
It looks like it uses some JOptionPanes to ask a question and display a result.
so this runs properly
What does "properly" mean?
I think you need to read up on GUI programming if you want to change the code.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
The basic things to consider when moving an application to an applet is to have all the components that are added to the JFrame's contentPane be added to the JApplet which extends Pane or to a JPanel which is added to the applet.
The other things to consider is where to put initialization code. Applets have several methods that are called by the browser. It does NOT call a main() method.
You can do some things in the constructor, but most should be done in the init() method.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656