Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with Swing Applets 1

Status
Not open for further replies.

fid

Programmer
May 10, 2001
20
US
I'm a web programmer, but new to Java.
I'm trying to write some Java Applets to learn, but getting hung at this error.

when i try using Swing Applets, they run fine with NetBeans and run fine compiled and run with AppletViewer.
but when I try loading it into Internet Explorer, I get errors. I've gotten regular AWK Applets to run fine in the browser, just having problems using Swing.

Here's my program and the compile so you can see what I did.
Hope it's not too much spam ;)
Thanks

import javax.swing.JOptionPane;

public class JTestPane extends javax.swing.JApplet {

public JTestPane() {
initComponents();
JOptionPane.showMessageDialog(null,"Hello!");
}

private void initComponents() {
jLabel1 = new javax.swing.JLabel();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;

jLabel1.setText("I Am Here");

gridBagConstraints1 = new java.awt.GridBagConstraints();
getContentPane().add(jLabel1, gridBagConstraints1);

}
private javax.swing.JLabel jLabel1;
}

C:\Inetpub\ JTestPane.java -verbose
[parsing started JTestPane.java]
[parsing completed 172ms]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/swing/JOptionPane.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/swing/JApplet.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/applet/Applet.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/Panel.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/Container.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/Component.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/lang/Object.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/image/ImageObserver.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/MenuContainer.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/io/Serializable.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/accessibility/Accessible.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/swing/RootPaneContainer.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/swing/JLabel.class)]
[checking JTestPane]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/lang/String.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(javax/swing/JComponent.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/GridBagLayout.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/LayoutManager.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/LayoutManager2.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/GridBagConstraints.class)]
[loading C:\compilers\jdk1.3.0_02\jre\lib\rt.jar(java/awt/PopupMenu.class)]
[wrote JTestPane.class]
[total 875ms]

>> First I try:
C:\Inetpub\ JTestPane.html
Works perfectly fine

>> But when I try:
C:\Inetpub\ Files\Internet Explorer\IEXPLORE.EXE" >> it gives me an error (in the browser status) and a blank applet
>> load: class JTestPane not found

I've written AWK Applets using java.applet.Applet and they run fine in my browser
seems when I try using Swing components it doesn't work.
What am I doing wrong?
 
Remember Swing has undergone many changes over the life of Java. Browsers, especially IE, use older versions of jdk. I think IE now uses 1.1. So precisely for this reason, it is not good practice to develop Applets that use the features of the newer jdks. When in doubt you should always deploy the applet with any dependant classes jared with it. Wushutwist
 
If you use Swing classes, you need to convert your htl using java's html converter, downloadable from java.sun.com for the version of java you are using.
 
ah thanks for help guys.
i used the html converter and got it working ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top