|
-
Jul 8th, 2007, 08:10 PM
#1
Thread Starter
Addicted Member
Applets and swing
I'm developing a web-based applet and I want it to open an external swing form that's stored in a separate class.
Basically can someone just show me how to open a blank JPanel that is stored in a separate class file from an applet running in a browser? I believe I can do anything beyond that on my own. Any tips would be appreciated though.
On another note:
I'm pretty advanced with Java but I just have very little experience with applets. Would you recommend using the java.applet.Applet class or the swing JApplet class for my applets? Is there any big difference?
-
Jul 9th, 2007, 12:56 AM
#2
Re: Applets and swing
I didn't understand your question very well.
I think to use a panel in your applet all you need is to include it's class path in the "classpath" when building the applet.
About your second question. If your applet uses animation it'd be better to use the java.applet.Applet. But if you'll be using it as a web form the javax.swing.JApplet would be better (it's just a graphics thing)
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 10th, 2007, 02:04 PM
#3
Frenzied Member
Re: Applets and swing
asically can someone just show me how to open a blank JPanel that is stored in a separate class file from an applet running in a browser? I believe I can do anything beyond that on my own. Any tips would be appreciated though.
extend JDialog and add the JPanel to it's container. It's just like a JFrame so you can customize the way it looks and you can easily call it from an Applet.
I'm pretty advanced with Java but I just have very little experience with applets. Would you recommend using the java.applet.Applet class or the swing JApplet class for my applets? Is there any big difference?
JApplet.
-
Jul 11th, 2007, 03:30 PM
#4
Thread Starter
Addicted Member
Re: Applets and swing
 Originally Posted by System_Error
extend JDialog and add the JPanel to it's container. It's just like a JFrame so you can customize the way it looks and you can easily call it from an Applet.
Can you give me a quick code snippet maybe of how you're saying to set this up? I tried what you said and it's not working for me.
-
Jul 12th, 2007, 07:43 PM
#5
Frenzied Member
Re: Applets and swing
Here's a really crude example:
Code:
import javax.swing.*;
import java.awt.event.*;
public class Test extends JApplet implements ActionListener
{
private JButton btn;
public void init()
{
btn = new JButton("Test");
btn.addActionListener(this);
getContentPane().add(btn);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == btn) new TestBox();
}
}
class TestBox extends JDialog
{
public TestBox()
{
setSize(200,200);
setVisible(true);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|