?
Solved

Running an Applet (jdk 1.1.7) in IE 5

Posted on 2001-06-14
5
Medium Priority
?
188 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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:
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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