• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use split JSplitpane

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In this program i used trees, to display ldif file.. and all the dn's and their properties are displaying but my need is if i click on Nodes then the properties of that node will be displayed seperately ie; the frame had to divided in to two halfs..the properties are displayed in second half

please help me if anyone knows..
--------------------------------------------------------------



import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

import javax.swing.JPanel;

import com.sun.org.apache.xpath.internal.patterns.NodeTest;




import javax.swing.*;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.StringReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileReader;

public class LDIFTree
{

public LDIFTree() throws FileNotFoundException
{


FileReader fr;
fr = new FileReader("c://data.ldif");

//FileReader fr= new FileReader("c://data.ldif");
JFrame f = new JFrame("LDIFTree");
BufferedReader reader = new BufferedReader(fr);
JTree tree = new JTree(new DefaultTreeModel(buildModel(reader)));
f.getContentPane().add(new JScrollPane(tree));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
private TreeNode buildModel(BufferedReader reader)
{
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root", true);
DefaultMutableTreeNode currentChild = null;
try
{
String line = reader.readLine();
while(line != null)
{
line = line.trim();
if (line.startsWith("dn"))
{
// add the current dn to the root
currentChild = new DefaultMutableTreeNode(line, true);
root.add(currentChild);
}
// else if (line.startsWith("-") || line.length() < 1)
// { // skip it
//} else
{
// add the property to the current dn
DefaultMutableTreeNode propertyNode = new DefaultMutableTreeNode(line, false);
currentChild.add(propertyNode);
}
line = reader.readLine();
}
}

catch (IOException x)
{
x.printStackTrace();
}
return root;
}




public static void main(String[] args) throws FileNotFoundException
{
new LDIFTree();
}
}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have a read of this thread (36 replies) - it's a bit of reading, but
some parts of it might give you an idea to do what you want.

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=5117006
 
reply
    Bookmark Topic Watch Topic
  • New Topic