Reputation: 2174
I have a java applet and I want to add a pre-designed Jpanel on my jpanel as a form. My Jpanel form is in another java file called MyForm.java. my JavaApplet class code is:
public class JavaApplet extends JApplet{
@Override
public void init(){
Container container = this.getContentPane();
container.add(new MyForm());
}
}
My html code to run this page is as simple:
<HTML>
<HEAD>
<TITLE>The Palindrome Page</TITLE>
</HEAD>
<BODY>
<P>My favorite meat-related palindrome is:
<BR>
<APPLET CODE="JavaApplet.class" WIDTH=600 HEIGHT=100>
A secret if your browser does not support Java!
</APPLET>
</BODY>
</HTML>
now can I put both .class files (MyForm.clsss & JavaApplet.cleass) in htmls file? Is it necessary to put all of my code in single file?
thank you
Upvotes: 0
Views: 595
Reputation: 168825
MyForm
to a frame instead of the applet. (You might create a frame in a main method and add it there.)In answer to your specific questions.
now can I put both .class files (MyForm.clsss & JavaApplet.cleass) in htmls file?
If the loose class files are both in the same directory (and package), they should be found. Safer though, to use a single Jar.
Is it necessary to put all of my code in single file?
Java source code file? No - definitely not. Classes? Recommend 1 Jar.
If using a Jar, you'd need an archive
attribute in the applet
element.
Upvotes: 1