Solved

Need to see my Applet in Netscape4.x and IE4.x

Posted on 1998-11-19
7
273 Views
Last Modified: 2013-11-23
I use JBuilder 2 client/server on WinNT4, Win95.
JBuilder 2 use JDK 1.1.6 and Swing 1.0.1, by default.

I build some Applet, in JBuilder everything work 100% ok.
But now when I try to test my Applet with Netscape4.x and IE4.x, Netscape I cann't have my applet and in IE4 I see a gray applet but nothing in.

In my test I just use one button and one label (in java.awt)on the applet, so nothing very exciting.

I need to know step by step how I can see my Applet in
Netscape 4.0x and 4.5.  And the same in Internet Explorer 4.x.

BTW how I use JRE like a plug-ins ?

Please be explicit....
Thanks, Zeric
0
Comment
Question by:Zeric
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227888
if you use only standard java classes you should see your applet in both browsers ... so maybe there is some Borland specific class that your applet needs ...

post here the sourse code and the erro message that you receive when you try to open the applet in both browsers (for NN chose Communicator/Java console) and maybe we can help ...
  heyhey
0
 

Author Comment

by:Zeric
ID: 1227889
When I use Visual Cafe or JDK directly everything work well.  

But now I have a project with JBuilder so when I'm in environment every is OK, but when I try the HTML page that JBUILDER give to me I always receive in Netscape 4.5
Applet HelloApplet.MyApplet class HelloApplet.MyApplet could not be loaded

and in IE4 I don't receive any error, just gray applet I don't see nothing in my applet.


I test with JBUILDER 1.0 too and I have the same problem.... here the structure in JBuilder 1.0

h:\JBuilder\myprojects\MyApplet.html
h:\JBuilder\myprojects\MyApplet.java
h:\JBuilder\myprojects\HelloApplet.jpr    <=== project file

the compiles files are in an other directory
h:\JBuilder\myclasses\MyApplet.class
h:\JBuilder\myclasses\MyApplet_button1_actionAdapter.class

==============================================

<HTML>
<TITLE>
My Applet HTML test
</TITLE>
<BODY>
MyApplet will appear below in a Java enabled browser.<BR>
<APPLET
  CODEBASE = "."
  CODE     = "HelloApplet.MyApplet.class"
  NAME     = "MyApplet"
  WIDTH    = 400
  HEIGHT   = 300
  HSPACE   = 0
  VSPACE   = 0
  ALIGN    = Middle
>
</APPLET>
</BODY>
</HTML>
================================================
Here my java code source in h:\JBuilder\myprojects\MyApplet.java

package HelloApplet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;

public class MyApplet extends Applet {
  XYLayout xYLayout1 = new XYLayout();
  boolean isStandalone = false;
  Label label1 = new Label();
  Button button1 = new Button();

  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
  public MyApplet() {
  }

  //Initialize the applet
  public void init() {
    try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
  }

  //Component initialization
  public void jbInit() throws Exception{
    xYLayout1.setWidth(400);
    xYLayout1.setHeight(300);
    label1.setText("Bienvenue");
    button1.setLabel("Bonjour");
    button1.addActionListener(new MyApplet_button1_actionAdapter(this));
    this.setLayout(xYLayout1);
    this.add(label1, new XYConstraints(38, 39, 111, 42));
    this.add(button1, new XYConstraints(26, 110, 117, 50));
  }

  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }

  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }

  void button1_actionPerformed(ActionEvent e) {
    label1.setText("Bonjour");
  }
}

class MyApplet_button1_actionAdapter implements java.awt.event.ActionListener {
  MyApplet adaptee;

  MyApplet_button1_actionAdapter(MyApplet adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.button1_actionPerformed(e);
  }
}


Thanks
Zeric
0
 

Author Comment

by:Zeric
ID: 1227890
I forgot, in my other test in JBuilder 2.0 I use Swing...
Thanx
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:heyhey_
ID: 1227891
I don't see any 'not pure' java code except these lines

>> import borland.jbcl.layout.*;
>> import borland.jbcl.control.*;
(and maybe the XYLayout)

so if you take them away the applet will probably work
if you use some specific Borland classes in your applet, you should distribute them with the applet ...
read Borland documentation for more information ...
if you use Swing in your applet, you should check the article "Make your browser Swing" at Javasoft's Swing Connection

hope this helps
  heyhey
0
 

Author Comment

by:Zeric
ID: 1227892
It'sn't solve my problem.
JBW, I remove import borland.jbcl.layout.*; reference and it's always not load my applet (or japplet for my other swing exemple).  So the problem it's somewhere in the organisation directory and in my html code, but I don't see.

I put the plug-ins java-1.1.1 in my Netscape browser, the problem persited....

I made many other Java application and applet with Visual Cafe or directly with JDK, and it was always working.... and know just because I change for JBuilder it'sn't working in Netscape, but it's work very well in the appletviewer in JBuilder...

Thanks.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227893
in Netscape go to the menu
"Communicator / Java Console"

open the console.
load your applet
check the console to see what's the error message - and post it here

most probably your applet uses some BOrland specific classes that can't be found from Netscape.

0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 200 total points
ID: 1227894
so
1.)
modify your code, so that it use only standard Java classes
(at the moment you use XYLayout that is Borland extension)

---- start

package HelloApplet;
      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;

      public class MyApplet extends Applet {
//        XYLayout xYLayout1 = new XYLayout();
        LayoutManager xYLayout1 = new GridLayout(2,1);
        boolean isStandalone = false;
        Label label1 = new Label();
        Button button1 = new Button();

        //Get a parameter value
        public String getParameter(String key, String def) {
          return isStandalone ? System.getProperty(key, def) :
            (getParameter(key) != null ? getParameter(key) : def);
        }

        //Construct the applet
        public MyApplet() {
        }

        //Initialize the applet
        public void init() {
          try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
        }

        //Component initialization
        public void jbInit() throws Exception{
//          xYLayout1.setWidth(400);
//          xYLayout1.setHeight(300);
          label1.setText("Bienvenue");
          button1.setLabel("Bonjour");
          button1.addActionListener(new MyApplet_button1_actionAdapter(this));
          this.setLayout(xYLayout1);
//          this.add(label1, new XYConstraints(38, 39, 111, 42));
//          this.add(button1, new XYConstraints(26, 110, 117, 50));
          this.add(label1);
          this.add(button1);
        }

        //Get Applet information
        public String getAppletInfo() {
          return "Applet Information";
        }

        //Get parameter info
        public String[][] getParameterInfo() {
          return null;
        }

        void button1_actionPerformed(ActionEvent e) {
          label1.setText("Bonjour");
        }
      }

      class MyApplet_button1_actionAdapter implements java.awt.event.ActionListener {
        MyApplet adaptee;

        MyApplet_button1_actionAdapter(MyApplet adaptee) {
          this.adaptee = adaptee;
        }

        public void actionPerformed(ActionEvent e) {
          adaptee.button1_actionPerformed(e);
        }
      }

---- end

since you use packeges put the applet classes one direrectory deeper than the HTML file

so if the html is here
      h:\JBuilder\myprojects\MyApplet.html

put the class files here
      h:\JBuilder\myclasses\HelloApplet\MyApplet.class
      h:\JBuilder\myclasses\HelloApplet\MyApplet_button1_actionAdapter.class

I've TESTED this and i can see the apllet with AppletViewer NC and IE.
the applet uses only standard java clases so it will work everywhere ...

(Note:
If you need to use some specific Borland classes in your applet, you should distribute these classes with the applet ...
Please, Read Borland documentation for more information on how to do this ...
If you need to use Swing in your applet, this applet can be viewd only with browsers the Support Swing, Please Read the article "Make your browser Swing" at Javasoft's Swing Connection
)

so now it is PureJava and it works.
More problems ?
 
  heyhey
P.S.
>> JBW, I remove import borland.jbcl.layout.*; reference and it's always not load my applet
if you have remove import borland.* lines you  won't be able even to compile the applet since XYLayout is borlad class.
>> but it's work very well in the appletviewer in JBuilder...
it do, of course, but i know how to use all the Borland specific clases, and Swing classes ... and NC does not.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get weblogic logged in user in java 2 57
print map entry 34 54
map related example 6 32
java jdbc batch example 8 20
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now