Solved

2-3 Tree Archiv

Posted on 2004-10-12
15
373 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
[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
  • 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
Technology Partners: 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!

 
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
 
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 74
eclipse buid path vs tomcat lib path 10 38
ejb message driven bean mdb creation steps 2 37
Crystal Reports Licensing Questions 4 65
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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