ok in Netscape, applet does not display in IE

Posted on 2000-05-11
Last Modified: 2010-04-01
I have a somewhat simple Applet that displays ok in Netscape 4.5 but I just get a grey box in IE 5.0 - any ideas?  I guess it is probably some var that needs to be set differently depending on the browser.  I've tried everything I can think of with my limited java experience.
Thanks! -BB

Here is most of the code:

import java.applet.*;

public class t9citypair extends Applet {
    List attcoaList = new List(22, false);
    List attcozList = new List(22, false);
    List speedList = new List(4, false);
        Button priceButton = new Button("Price");
        TextField costTextField = new TextField(13);
        TextField dateTextField = new TextField(12);
        TextArea miscTextArea = new TextArea("", 15, 38);
        Font lblFont = new Font("Times", Font.BOLD, 12);
        Font effdateFont = new Font("Times", Font.BOLD, 14);
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints constr = new GridBagConstraints();
    Font f;
        public void init() {
        f = new Font("Monospaced", Font.PLAIN, 12);
        constr.insets = new Insets(2, 2, 2, 2);
        setBackground(new Color(0xC0C0C0));

        Label speedLabel = new Label("Speed");
        constr.gridx=0; constr.gridy=0; constr.gridwidth=2; constr.gridheight=1;
        constr.weightx = 0.0; constr.weighty = 0.0;
        gbl.setConstraints(speedLabel, constr);

        constr.gridx=0; constr.gridy=1; constr.gridwidth=2; constr.gridheight=3;
        constr.weightx = 0.0; constr.weighty = 1.0;
        gbl.setConstraints(speedList, constr);

        constr.gridx=4; constr.gridy=18; constr.gridheight=1;
        gbl.setConstraints(dateTextField, constr);

        DataInputStream is;
        try {
            URL url = new URL("http:/  .......           " + speedList.getSelectedItem());
            is = new DataInputStream (url.openStream());
            String c = is.readLine() ;
            int nummisc = (new Integer(c)).intValue();
            int indx;

            miscTextArea.setText("Misc Charges for Speed " + speedList.getSelectedItem() + ":\n\n");

            for(indx=0; indx < nummisc; indx++) {
                c = is.readLine() ;
                miscTextArea.appendText(c + "\n");
        } catch(Exception e) {
            miscTextArea.setText("Problem getting Misc. Charges");

        try {
            URL url = new URL("http:/   ...................    " + speedList.getSelectedItem());              
            is = new DataInputStream (url.openStream());
            String c = is.readLine() ;
            int numcities = (new Integer(c)).intValue();
            int indx;

            for(indx=0; indx < numcities; indx++) {
                c = is.readLine() ;
        } catch(Exception e) {
            System.out.println("Exception getting city list" + e);

                try {

Question by:borghard

Accepted Solution

falter earned 134 total points
ID: 2802455
I think you are miss using the init() method.
There is a hint in Java in a Nutshell saying:
the applet isn't controling the execution thread it has to respond to the browser calls, so every method
start(), stop(), init(), destroy() have to return immediatley. Its not allowed to have a time consuming task or infinite loop in f.e. the init method.
If you wanna do such things you have to start your own thread.

I have als mentioned that Netscape is very tolerant to applets doing all the stuff in their init method, but they shouldn't do so.

If you didn't return from your init method you will block the event queue means your browser gets frozen.

Think of init in applets like a constructor and I don't think you will code your whole application stuff in a constructor.


Expert Comment

ID: 2803168
Try using the html converter  to generate the HTML page for applet. Html converter can be downloaded from

Author Comment

ID: 2811576
Thanks both for the info!

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 104
allswap challenge 6 96
JList custom Cell Renderer refresh 15 56
Facing this issue for maven proxy setting 2 9
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

785 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