[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

2-3 Tree Archiv

Posted on 2004-10-12
15
Medium Priority
?
378 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
 

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 5

Accepted Solution

by:
Naeemg earned 450 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

656 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