Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Running an Applet (jdk 1.1.7) in IE 5

Posted on 2001-06-14
5
Medium Priority
?
194 Views
Last Modified: 2013-11-23
Hi,

I try to run an applet contenting a JTree in IE 5 but the Tree does not expand/collapse and the Scrollbar is not working. Only if I force a repaint (by changing the screen) the expanded Tree is visible.

What can I do to make it run ?

FFengler
0
Comment
Question by:FFengler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:iDeb
ID: 6192443
please post your code for reference....
0
 

Author Comment

by:FFengler
ID: 6192492
Here's the code


There are 4 classes altogether, JDK 1.1.7 is used.

import java.awt.*;
import java.applet.*;
import com.sun.java.swing.JScrollPane;
import com.sun.java.swing.JTree;
import com.sun.java.swing.JButton;
import java.net.*;
import com.sun.java.swing.event.*;

public class PDHApplet extends Applet
{
    private PdhInput pdh;
   
      public void init()
      {
            
            
            //{{INIT_CONTROLS
            setLayout(null);
            setBackground(java.awt.Color.lightGray);
            setSize(693,540);
            
            try{
            pdh=new PdhInput(getDocumentBase());
            pdh.loadPdh();
            Baum b=new Baum();
            JTree1 = new com.sun.java.swing.JTree(b.createTree(pdh));
        }catch(Exception ex){}
            JScrollPane1.setOpaque(true);
            add(JScrollPane1);
            
            JScrollPane1.setBounds(36,48,624,435);
            JScrollPane1.getViewport().add(JTree1);
            JTree1.setBounds(0,0,621,432);
            //}}
      
          TreeControl control=new TreeControl();
          JTree1.addTreeExpansionListener(control);
      }
      
      
      //{{DECLARE_CONTROLS
      com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
      com.sun.java.swing.JTree JTree1;
      //}}



      public class TreeControl implements TreeExpansionListener{
          public void treeCollapsed(TreeExpansionEvent event){
              JTree1.repaint();
          }
          
          
          public void treeExpanded(TreeExpansionEvent event){
              JTree1.repaint();
          }
      }
}



import com.sun.java.swing.*;
import com.sun.java.swing.tree.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.net.*;

public class Baum

{

   
   
    private Vector pdhdata;
    private PdhEintrag entry;
    private int s;
    private Hashtable nodeList=new Hashtable();
   
   
 public DefaultMutableTreeNode createTree(PdhInput pdh)
 {
    int count=0;
    pdhdata=pdh.getPdh();
    s=pdhdata.size();
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    DefaultMutableTreeNode wurzel=new DefaultMutableTreeNode("Produkthierarchie");
   
   
   while(count<=s){
    entry=(PdhEintrag)pdhdata.elementAt(count);
    node=new DefaultMutableTreeNode(entry.getName());
    nodeList.put(entry.getName(),node);
    if (entry.getParent().equals("ROOT")){
      wurzel.add(node);
    }else{
      parent=this.findNode(entry.getParent(),nodeList);
      if (parent==null){
        int anz=wurzel.getChildCount();
        break;
      }else{
        parent.add(node);
      }
    }
    count++;
   
   };
  //  this.saveTree(wurzel);
    return wurzel;
 }
 
 
 private DefaultMutableTreeNode findNode(String name, Hashtable nodeList){
 
   //Enumeration e;
   DefaultMutableTreeNode node=new DefaultMutableTreeNode();
   if (nodeList.containsKey(name)){
     return (DefaultMutableTreeNode) nodeList.get(name);
   } else{
     return null;
   }
 }

 
}



import java.awt.*;
import java.util.*;
import java.io.*;
import java.net.*;

public class PdhInput
{
  private Vector pdhdata= new Vector();
  private final String FILENAME="PDH.csv";
  private URL fileUrl;
 
  public PdhInput(URL baseURL) throws Exception{
    String path=baseURL.getFile();
    path=path.substring(0,path.lastIndexOf('/')+1);
    path=path+FILENAME;
    fileUrl=new URL(baseURL.getProtocol(),baseURL.getHost(),baseURL.getPort(),path);
  }
 
  public void loadPdh()throws Exception
  {
    int pos;
    int index;
    int i;

    StringTokenizer T;
   
   
    try{
        BufferedReader br = new BufferedReader( new InputStreamReader(fileUrl.openStream()) );
        String str;
        while((str=br.readLine())!=null){
          T=new StringTokenizer(str,";");
          String s1=T.nextToken();
          String s2=T.nextToken();
          String s3=T.nextToken();
          String s4=T.nextToken();
          String s5=T.nextToken();
          s4=s4.concat(" ");
          s4=s4.concat(s5);
         
          PdhEintrag e=new PdhEintrag(s1,s2,s3,s4);
          pdhdata.addElement(e);
        }
        br.close();
    }catch(IOException e){}
  }

  public Vector getPdh()
  {
      return this.pdhdata;
  }

 
 
 
 
 
}

public class PdhEintrag
{
    private String name;
    private String parent;
    private String stufe;
    private String nummer;
   
    public PdhEintrag()
    {
        name="";
        parent="0";
        stufe="0";
        nummer="0";
    }
   
    public PdhEintrag(String nummer, String stufe, String parent, String name)
    {
      this.nummer=nummer;
      this.name=name;
      this.parent=parent;
      this.stufe=stufe;
    }
   
    public void setName(String name)
    {
        this.name=name;
    }
    public void setParent(String parent)
    {
        this.parent=parent;
    }
    public void setStufe(String stufe)
    {
        this.stufe=stufe;
    }
    public void setNummer(String nummer)
    {
        this.nummer=nummer;
    }
   
   
    public String getNummer()
    {
        return nummer;
    }
   
    public String getParent()
    {
        return parent;
    }
    public String getStufe()
    {
        return stufe;
    }
    public String getName()
    {
        return name;
    }
   
    public void setEntry(String nummer, String stufe, String parent, String name)
    {
        this.nummer=nummer;
        this.name=name;
        this.parent=parent;
        this.stufe=stufe;
    }
   
    public PdhEintrag getEntry()
    {
        return this;
    }
   
}
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6193336
Hi,

I would suggest to update swing version to 1.1.1 (latest 1.1 compatible version). Probably it will solve many problems.

Regards,
Igor Bazarny
Brainbench MVP for Java 1
www.brainbench.com
0
 
LVL 1

Accepted Solution

by:
tonus earned 200 total points
ID: 6193921
Hi,
  Instead of painting JTree, paint the applet itself by calling the repaint() method whereever you called the JTree.repaint(). Override the paint method as given below.


public void paint(Graphics g){
this.validate();
super.paint(g);
}

this.validate() validates all the components added to the applet and repaints the component which has been changed.


 
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9033793
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to tonus]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

618 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