|
-
October 10th, 2005, 10:10 PM
#1
Boneheaded Applet Question
Hey everyone. I gave up on GridBagLayout for now, after discovering the usefullness of NetBeans 4.0 GUI form editor...
But I now have a different issue.
If I write an applet by hand that looks something like this:
Code:
public class Foo extends JApplet {
public void init() {
declare some stuff
create containers
create components
add components to containers
}
}
I can run that applet embedded in a basic html page and call the class involved like so:
<applet class="Foo.class" archive="Foo.jar"> </applet>
and when I load that page, my gui loads into the applet.
However, after discovering the gui form editor, I tried creating a really nice gui using that.
It too creates a form, as an applet but does it like so:
Code:
public class Foo extends javax.swing.JApplet {
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void initComponents(){
create container
config container
create componentA
config componentA
container.add(componentA, constraints)
create componentB
create componentB
container.add(componentB, constraints)
getContentPane().add(container, constraints)
}
}
and thats about it. So when I call THAT applet from an HTML page, I get an error on loading.
So here is the first question: if I use the form designer in NetBeans to create the GUI for the applet, what else do I need to add to get the gui to actually load and display? anything?
The next question regards the error I am getting, and has little to do with my first question.
after compiling the thing as a jar file, and trying to load it, the JRE throws and exception and I get this:
class not found
caused by java.io.FileNotFoundException (long path)/class.class
so it is trying to find the class in my development directory, but not pulling it from the compiled jar file???
Finally, the form designer does not import anything. It calles things directly. It does allow the use of AbsoluteLayout from org.netbeans.lib.awtextra however, which seems to work really well for creating a gui using specific item locations...
BUT, once I create the jar file that is called by the browser when it renders the applet tag, will it be able to find that? IN other words, when I design somethign in C, C++, or VB, anything I include in the code is compiled in (libraries and classes), so the necessary stuff is pulled into the final executable.
If I do this with an applet, when that applet is compiled from source to a jar file, does that process (using NetBeans and JDK 5.0) also pull in those external classes so that a JRE on a different machine will not have to call it??
Sorry, that last question is just one that I haven't quite figured out yet. Java, I am finding, works a lot like other OO languages, howver, in some respects it is quite different...
Thanks for the advice...
Jeff
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
|