Solved

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

Posted on 1998-11-19
7
271 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

760 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

21 Experts available now in Live!

Get 1:1 Help Now