Solved

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

Posted on 1998-11-19
7
274 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
recursion example 16 126
Spring Framework HTTPSession management 1 33
servlet example 11 40
MySqlDump not dumping triggers 1 31
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

770 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