Solved

Running an Applet (jdk 1.1.7) in IE 5

Posted on 2001-06-14
5
187 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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 …

729 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