Solved

2-3 Tree Archiv

Posted on 2004-10-12
15
370 Views
Last Modified: 2010-03-31
Hello!

I'm a student andi have a little problem with my homework. we have to build a small archiv for example mp3 or doc files..... I have my gui ready and now i have a small problem, i have to develop a 2-3 tree. The tree isn't the problem. The Problem is, how can i insert the values in the tree? That the informations about file don't get lose. and how can i display the informations on the gui? give it at swing method like "excel-look"? How can i change the order?

Thank you

Best regards
mystixs
0
Comment
Question by:mystixs
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12284861
See DefaultMutableTreeNode
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12284886
0
 

Author Comment

by:mystixs
ID: 12284908
Has everyone an example? for the tree or for displaying the data. it can be another program, but with a small "look-in" the program.
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12284923
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12284925
0
 

Author Comment

by:mystixs
ID: 12284956
I have already seen those tree's. But i mean an tree in the background for sorting the display data. the data should display like the following schedule:


---------------------------------------------------
|File1         |Date               |Time      |Title|
---------------------------------------------------
|File2         |Date               |Time      |Title|
---------------------------------------------------
|File3         |Date               |Time      |Title|
---------------------------------------------------
|File4         |Date               |Time      |Title|
---------------------------------------------------
|File5         |Date               |Time      |Title|
---------------------------------------------------

Do you know, what i mean?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12284963
That looks more like a table to me ;-)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:expertmb
ID: 12285023
its not a tree , its table
>>But i mean an tree in the background for sorting the display data. have a collection which will hold these data for you.
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12285025
have a collection which will hold these data for you.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12285038
0
 

Author Comment

by:mystixs
ID: 12285072
extpertmb, i would be nice, when you send me the data or have you the posibilty to upload the on a websever? that a can download me the data?
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12285139
0
 
LVL 5

Accepted Solution

by:
Naeemg earned 150 total points
ID: 12285215
use the following code according to ur requirements

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.ImageIcon;
import java.net.URL;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;

public class Tree extends JFrame {
    //private JEditorPane htmlPane;
    //private static boolean DEBUG = false;
    //private URL helpURL;

    public Tree() {
        //super("TreeIconDemo");

        //Create the nodes.
        DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
        createNodes(top);

        //Create a tree that allows one selection at a time.
        final JTree tree = new JTree(top);
        tree.getSelectionModel().setSelectionMode
                (TreeSelectionModel.SINGLE_TREE_SELECTION);


        //Create the scroll pane and add the tree to it.
        JScrollPane treeView = new JScrollPane(tree);


        //Add the scroll panes to a split pane.
        JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        splitPane.setTopComponent(treeView);
        splitPane.setPreferredSize(new Dimension(500, 300));

        //Add the split pane to this frame.
        getContentPane().add(splitPane, BorderLayout.CENTER);
            tree.setShowsRootHandles( true );
    }



    private void createNodes(DefaultMutableTreeNode top) {
        DefaultMutableTreeNode category = null;
        DefaultMutableTreeNode book = null;

        category = new DefaultMutableTreeNode("Books for Java Programmers");
        top.add(category);

        //original Tutorial
        book = new DefaultMutableTreeNode("The Java Tutorial: Object-Oriented Programming for the Internet");
        category.add(book);

        //Tutorial Continued
        book = new DefaultMutableTreeNode("The Java Tutorial Continued: The Rest of the JDK");
        category.add(book);

        //JFC Swing Tutorial
        book = new DefaultMutableTreeNode("The JFC Swing Tutorial: A Guide to Constructing GUIs");
        category.add(book);

        //Arnold/Gosling
        book = new DefaultMutableTreeNode("The Java Programming Language");
        category.add(book);

        //FAQ
        book = new DefaultMutableTreeNode("The Java FAQ");
        category.add(book);

        //Chan/Lee
        book = new DefaultMutableTreeNode("The Java Class Libraries: An Annotated Reference");
        category.add(book);

        //Threads
        book = new DefaultMutableTreeNode("Concurrent Programming in Java: Design Principles and Patterns");
        category.add(book);

        category = new DefaultMutableTreeNode("Books for Java Implementers");
        top.add(category);

        //VM
        book = new DefaultMutableTreeNode("The Java Virtual Machine Specification");
        category.add(book);

        //Language Spec
        book = new DefaultMutableTreeNode("The Java Language Specification");
        category.add(book);
    }



    public static void main(String[] args) {
        JFrame frame = new Tree();

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        frame.pack();
        frame.setVisible(true);
    }
}

//Naeem Shehzad Ghuman
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12290419
?
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12294342
strange. moderator/venabili can you plz look into such questions.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exception after setting jdbc session management 2 52
mapAB Challlenge 35 126
Java SE 8u111  Lot of stuff broke 11 54
oracle 11g 23 50
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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:
This video teaches viewers about errors in exception handling.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now