About to use my tree for firewood

I was wondering if someone could maybe clue me into a problem that I am having with my DefaultMutableTree. See, I call a recursive method to get the file system of the computer, which is what is added to the tree. So the user is looking at a tree structure of the file system of their computer. My problem is that when I compile and run my program the tree shows up fine, with no hitches. I have given my code to other friends, and for some of them it does not show up, and throws a null pointer exception at the internal interface of this recursive method. I was wondering what might be causing this? My friends that have problems with the code are running either WIN XP, or Mac OS 10.1.4. Here is the code for the initialization of the tree (This will look ugly on the post, so I would hope that you would take the time to copy and paste this into your editor :D)
//code start.
import java.io.*;
import java.io.File;
import java.lang.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.beans.*;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.TreeSelectionModel;
public class File_Encryptor extends JFrame {
private JFrame thisFrame = this;
          private JTree tree;
private JMenuBar jMenuBar1 = new JMenuBar();
          private JMenuItem menuOpen = new JMenuItem("Open");
          private JMenuItem menuSave = new JMenuItem("Save");
          private JMenuItem menuClose = new JMenuItem("Close");
          private JMenuItem menuQuit = new JMenuItem("Quit");
          private JMenuItem menuAbout = new JMenuItem("About this software...");
          private JMenuItem menuAdd = new JMenuItem("Add key and user");
          private JMenuItem menuChange = new JMenuItem("Change buddy key");
          private JMenuItem menuSend = new JMenuItem("Send your buddy key");
          private JMenuItem menuDelete = new JMenuItem("Delete selected buddy key");
          private JMenuItem menuReset = new JMenuItem("Reset your key");
          private JMenuItem menuChangeLogin = new JMenuItem("Change Login");
          private JMenuItem menuHelp = new JMenuItem("Help...");
          private JButton openDir = new JButton("Open path");
          private JTextField jTextField1 = new JTextField();
          private JScrollPane treeView;
          private JScrollPane imageView;
          private JScrollPane textView;
          private String ROOT;
          private File root;
          private DefaultMutableTreeNode top;
          final private DefaultMutableTreeNode FILLER = new DefaultMutableTreeNode(new FileInfo ("about:blank", "about:blank"));
     public File_Encryptor() throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
super("FILE ENCRYPTOR 1.0");
               addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
                    System.exit(0);
               ROOT = getRoot(System.getProperty("user.home"));
               root = new File(ROOT);                    
               try{
               //Create the nodes.
               top = unfold(root);
               top.setUserObject(new FileInfo(ROOT,ROOT));
               tree = new JTree(top);
               tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
               Object nodage = top.getNextNode().getUserObject();
               FileInfo leaf = (FileInfo) nodage;
               tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
if (node == null) return;
          try{
                    Object nodeInfo = node.getUserObject();
                    FileInfo temp = (FileInfo) nodeInfo;
                    if((node.isLeaf()) && (!(node.isRoot())))
                         System.out.println(temp.Path());
                         //figure out how to place file in editor pane.
                    else
                         return;
               catch(Exception fubar)
                    fubar.printStackTrace();
               treeView = new JScrollPane(tree);
               treeView.setSize(150,450);
               jTextField1.setMaximumSize(new Dimension(50, 100));
               jTextField1.setText("PATH");
               this.getContentPane().add(jTextField1, BorderLayout.EAST);
               this.getContentPane().add(treeView, BorderLayout.WEST);
catch(Exception e) {
e.printStackTrace();
               jMenuBar1.setBorder(BorderFactory.createEtchedBorder());
               JMenu menu = new JMenu("File");
               JMenu about = new JMenu("Help");
               JMenu keys = new JMenu("Keys");
               JMenu change = new JMenu("Login");
               menuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.META_MASK));
               menuQuit.setEnabled(true);
               menuQuit.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                         System.exit(0);
               menu.add(menuQuit);
               jMenuBar1.add(menu);
               jMenuBar1.add(keys);
               jMenuBar1.add(change);
               jMenuBar1.add(about);
               this.setJMenuBar(jMenuBar1);
          public class FileInfo {
          private String path = "";
          private String name = "";
          public FileInfo(String p , String n){
               path = p;
               name = n;
          public String toString(){
               return name;
          public String Path(){
               return path;
          public static String getFileEx(String po){
          String ext = "";
          int i = po.lastIndexOf('.');
          if(i > 0)
               ext = po.substring(i-1);
          else
               ext = null;
          return ext;
          private DefaultMutableTreeNode unfold(File path) {
               DefaultMutableTreeNode node = new DefaultMutableTreeNode("");
               Vector Files = new Vector();
               Vector Direc = new Vector();
               if((path.isDirectory()) && (path.list().length != 0))
                    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
                    File [] childs = path.listFiles();
                    for(int j = 0; j < childs.length; j++)
                         if(childs[j].isDirectory())
                              Direc.addElement(childs[j]);
                         else
                              Files.addElement(childs[j]);
                    for(int g = 0; g < Files.size(); g++)
                         Direc.addElement((File)Files.elementAt(g));
                    for(int i = 0; i < Direc.size(); i++)
                         node.add(unfold((File)Direc.elementAt(i)));
               else if(!(path.isDirectory()))
                    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
               else
                    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
                    node.add(new DefaultMutableTreeNode(new FileInfo(null,"<EMPTY FOLDER>")));
               return node;
          public static String getRoot(String path)
               int find = path.indexOf(System.getProperty("file.separator"));
               String root = path.substring(0,find + 1);
               return root;
public static void main( String [ ] args )throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
File_Encryptor show = new File_Encryptor();
show.setSize(700, 500);
show.setResizable(false);
//show.setLocation(100,100);
show.setVisible(true);
//code end.
//well there it is. Hope someone can help me with my problem.
//I know this code is ugly, but I was trying a bunch of different
//things hoping something would work. but ehh no such luck.
//I am running windows 98, yea that's prolly my problem.
//thank you for your time.

This will make the code less ugly.
> //code start.
import java.io.*;
import java.io.File;
import java.lang.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.beans.*;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.TreeSelectionModel;
public class File_Encryptor extends JFrame {
private JFrame thisFrame = this;
          private JTree tree;
private JMenuBar jMenuBar1 = new JMenuBar();
          private JMenuItem menuOpen = new JMenuItem("Open");
          private JMenuItem menuSave = new JMenuItem("Save");
private JMenuItem menuClose = new
w JMenuItem("Close");
          private JMenuItem menuQuit = new JMenuItem("Quit");
private JMenuItem menuAbout = new JMenuItem("About this software...");
private JMenuItem menuAdd = new JMenuItem("Add key and user");
private JMenuItem menuChange = new JMenuItem("Change buddy key");
private JMenuItem menuSend = new JMenuItem("Send your buddy key");
private JMenuItem menuDelete = new JMenuItem("Delete selected buddy key");
private JMenuItem menuReset = new JMenuItem("Reset your key");
private JMenuItem menuChangeLogin = new
w JMenuItem("Change Login");
private JMenuItem menuHelp = new
w JMenuItem("Help...");
          private JButton openDir = new JButton("Open path");
          private JTextField jTextField1 = new JTextField();
          private JScrollPane treeView;
          private JScrollPane imageView;
          private JScrollPane textView;
          private String ROOT;
          private File root;
          private DefaultMutableTreeNode top;
final private DefaultMutableTreeNode FILLER = new
w DefaultMutableTreeNode(new FileInfo ("about:blank",
"about:blank"));
public File_Encryptor() throws FileNotFoundException,
InterruptedException, IOException,
ClassNotFoundException {
super("FILE ENCRYPTOR 1.0");
               addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
dowEvent e) {
                    System.exit(0);
               ROOT = getRoot(System.getProperty("user.home"));
               root = new File(ROOT);                    
               try{
               //Create the nodes.
               top = unfold(root);
               top.setUserObject(new FileInfo(ROOT,ROOT));
               tree = new JTree(top);
               tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
               Object nodage = top.getNextNode().getUserObject();
               FileInfo leaf = (FileInfo) nodage;
tree.addTreeSelectionListener(new
ew TreeSelectionListener() {
public void
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node =
TreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
if (node == null) return;
          try{
                    Object nodeInfo = node.getUserObject();
                    FileInfo temp = (FileInfo) nodeInfo;
                    if((node.isLeaf()) && (!(node.isRoot())))
                         System.out.println(temp.Path());
                         //figure out how to place file in editor pane.
                    else
                         return;
               catch(Exception fubar)
                    fubar.printStackTrace();
               treeView = new JScrollPane(tree);
               treeView.setSize(150,450);
jTextField1.setMaximumSize(new Dimension(50,
0, 100));
               jTextField1.setText("PATH");
this.getContentPane().add(jTextField1,
1, BorderLayout.EAST);
this.getContentPane().add(treeView,
w, BorderLayout.WEST);
catch(Exception e) {
e.printStackTrace();
               jMenuBar1.setBorder(BorderFactory.createEtchedBorder
               JMenu menu = new JMenu("File");
               JMenu about = new JMenu("Help");
               JMenu keys = new JMenu("Keys");
               JMenu change = new JMenu("Login");
               menuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEv
nt.VK_Q, ActionEvent.META_MASK));
               menuQuit.setEnabled(true);
               menuQuit.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                         System.exit(0);
               menu.add(menuQuit);
               jMenuBar1.add(menu);
               jMenuBar1.add(keys);
               jMenuBar1.add(change);
               jMenuBar1.add(about);
               this.setJMenuBar(jMenuBar1);
          public class FileInfo {
          private String path = "";
          private String name = "";
          public FileInfo(String p , String n){
               path = p;
               name = n;
          public String toString(){
               return name;
          public String Path(){
               return path;
          public static String getFileEx(String po){
          String ext = "";
          int i = po.lastIndexOf('.');
          if(i > 0)
               ext = po.substring(i-1);
          else
               ext = null;
          return ext;
          private DefaultMutableTreeNode unfold(File path) {
DefaultMutableTreeNode node = new
ew DefaultMutableTreeNode("");
               Vector Files = new Vector();
               Vector Direc = new Vector();
if((path.isDirectory()) && (path.list().length !=
!= 0))
node = new DefaultMutableTreeNode(new
new FileInfo(path.getPath(),path.getName()));
                    File [] childs = path.listFiles();
                    for(int j = 0; j < childs.length; j++)
                         if(childs[j].isDirectory())
                              Direc.addElement(childs[j]);
                         else
                              Files.addElement(childs[j]);
                    for(int g = 0; g < Files.size(); g++)
                         Direc.addElement((File)Files.elementAt(g));
                    for(int i = 0; i < Direc.size(); i++)
                         node.add(unfold((File)Direc.elementAt(i)));
               else if(!(path.isDirectory()))
node = new DefaultMutableTreeNode(new
new FileInfo(path.getPath(),path.getName()));
               else
node = new DefaultMutableTreeNode(new
new FileInfo(path.getPath(),path.getName()));
node.add(new DefaultMutableTreeNode(new
new FileInfo(null,"<EMPTY FOLDER>")));
               return node;
          public static String getRoot(String path)
int find =
=
path.indexOf(System.getProperty("file.separator"));
               String root = path.substring(0,find + 1);
               return root;
public static void main( String [ ] args
] args )throws FileNotFoundException,
InterruptedException, IOException,
ClassNotFoundException {
File_Encryptor show = new
show = new File_Encryptor();
show.setSize(700, 500);
show.setResizable(false);
//show.setLocation(100,100);
show.setVisible(true);
//code end.

Similar Messages

  • About to use my tree for some firewood  :o(

    I was wondering if someone could maybe clue me into a problem that I am having with my DefaultMutableTree. See, I call a recursive method to get the file system of the computer, which is what is added to the tree. So the user is looking at a tree structure of the file system of their computer. My problem is that when I compile and run my program the tree shows up fine, with no hitches. I have given my code to other friends, and for some of them it does not show up, and throws a null pointer exception at the internal interface of this recursive method. I was wondering what might be causing this? My friends that have problems with the code are running either WIN XP, or Mac OS 10.1.4. Here is the code for the initialization of the tree (This will look ugly on the post, so I would hope that you would take the time to copy and paste this into your editor :D)
    //code start.
    import java.io.*;
    import java.io.File;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.beans.*;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.tree.TreeSelectionModel;
    public class File_Encryptor extends JFrame {
    private JFrame thisFrame = this;
    private JTree tree;
    private JMenuBar jMenuBar1 = new JMenuBar();
    private JMenuItem menuOpen = new JMenuItem("Open");
    private JMenuItem menuSave = new JMenuItem("Save");
    private JMenuItem menuClose = new JMenuItem("Close");
    private JMenuItem menuQuit = new JMenuItem("Quit");
    private JMenuItem menuAbout = new JMenuItem("About this software...");
    private JMenuItem menuAdd = new JMenuItem("Add key and user");
    private JMenuItem menuChange = new JMenuItem("Change buddy key");
    private JMenuItem menuSend = new JMenuItem("Send your buddy key");
    private JMenuItem menuDelete = new JMenuItem("Delete selected buddy key");
    private JMenuItem menuReset = new JMenuItem("Reset your key");
    private JMenuItem menuChangeLogin = new JMenuItem("Change Login");
    private JMenuItem menuHelp = new JMenuItem("Help...");
    private JButton openDir = new JButton("Open path");
    private JTextField jTextField1 = new JTextField();
    private JScrollPane treeView;
    private JScrollPane imageView;
    private JScrollPane textView;
    private String ROOT;
    private File root;
    private DefaultMutableTreeNode top;
    final private DefaultMutableTreeNode FILLER = new DefaultMutableTreeNode(new FileInfo ("about:blank", "about:blank"));
    public File_Encryptor() throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
    super("FILE ENCRYPTOR 1.0");
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    ROOT = getRoot(System.getProperty("user.home"));
    root = new File(ROOT);
    try{
    //Create the nodes.
    top = unfold(root);
    top.setUserObject(new FileInfo(ROOT,ROOT));
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode
    (TreeSelectionModel.SINGLE_TREE_SELECTION);
    Object nodage = top.getNextNode().getUserObject();
    FileInfo leaf = (FileInfo) nodage;
    tree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
    tree.getLastSelectedPathComponent();
    if (node == null) return;
    try{
    Object nodeInfo = node.getUserObject();
    FileInfo temp = (FileInfo) nodeInfo;
    if((node.isLeaf()) && (!(node.isRoot())))
    System.out.println(temp.Path());
    //figure out how to place file in editor pane.
    else
    return;
    catch(Exception fubar)
    fubar.printStackTrace();
    treeView = new JScrollPane(tree);
    treeView.setSize(150,450);
    jTextField1.setMaximumSize(new Dimension(50, 100));
    jTextField1.setText("PATH");
    this.getContentPane().add(jTextField1, BorderLayout.EAST);
    this.getContentPane().add(treeView, BorderLayout.WEST);
    catch(Exception e) {
    e.printStackTrace();
    jMenuBar1.setBorder(BorderFactory.createEtchedBorder());
    JMenu menu = new JMenu("File");
    JMenu about = new JMenu("Help");
    JMenu keys = new JMenu("Keys");
    JMenu change = new JMenu("Login");
    menuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.META_MASK));
    menuQuit.setEnabled(true);
    menuQuit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    menu.add(menuQuit);
    jMenuBar1.add(menu);
    jMenuBar1.add(keys);
    jMenuBar1.add(change);
    jMenuBar1.add(about);
    this.setJMenuBar(jMenuBar1);
    public class FileInfo {
    private String path = "";
    private String name = "";
    public FileInfo(String p , String n){
    path = p;
    name = n;
    public String toString(){
    return name;
    public String Path(){
    return path;
    public static String getFileEx(String po){
    String ext = "";
    int i = po.lastIndexOf('.');
    if(i > 0)
    ext = po.substring(i-1);
    else
    ext = null;
    return ext;
    private DefaultMutableTreeNode unfold(File path) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("");
    Vector Files = new Vector();
    Vector Direc = new Vector();
    if((path.isDirectory()) && (path.list().length != 0))
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    File [] childs = path.listFiles();
    for(int j = 0; j < childs.length; j++)
    if(childs[j].isDirectory())
    Direc.addElement(childs[j]);
    else
    Files.addElement(childs[j]);
    for(int g = 0; g < Files.size(); g++)
    Direc.addElement((File)Files.elementAt(g));
    for(int i = 0; i < Direc.size(); i++)
    node.add(unfold((File)Direc.elementAt(i)));
    else if(!(path.isDirectory()))
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    else
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    node.add(new DefaultMutableTreeNode(new FileInfo(null,"<EMPTY FOLDER>")));
    return node;
    public static String getRoot(String path)
    int find = path.indexOf(System.getProperty("file.separator"));
    String root = path.substring(0,find + 1);
    return root;
    public static void main( String [ ] args )throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
    File_Encryptor show = new File_Encryptor();
    show.setSize(700, 500);
    show.setResizable(false);
    //show.setLocation(100,100);
    show.setVisible(true);
    //code end.
    //well there it is. Hope someone can help me with my problem.
    //I know this code is ugly, but I was trying a bunch of different
    //things hoping something would work. but ehh no such luck.
    //I am running windows 98, yea that's prolly my problem.
    //thank you for your time.

    I ran this on XP and got the null pointer exception...
    it's likely that it's running into a file or directory that it can't list (in my case it was a mount on a different directory ntfs is kinda cool)... SO... to handle that problem I just put the whole method in a try / catch block
    it was just the method unfold ... the fix returns a blank treenode... it should probably return null and the caller should see that as a sign to not add it to the tree...
         private DefaultMutableTreeNode unfold(File path) {
              DefaultMutableTreeNode node = new DefaultMutableTreeNode("");
              try
                   Vector Files = new Vector();
                   Vector Direc = new Vector();
                   if(path==null)
                        return(node);
                   if((path.isDirectory()) && (path.list().length != 0))
                   node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
                   File [] childs = path.listFiles();
                   for(int j = 0; j < childs.length; j++)
                   if(childs[j].isDirectory())
                   Direc.addElement(childs[j]);
                   else
                   Files.addElement(childs[j]);
                   for(int g = 0; g < Files.size(); g++)
                   Direc.addElement((File)Files.elementAt(g));
                   for(int i = 0; i < Direc.size(); i++)
                   node.add(unfold((File)Direc.elementAt(i)));
                   else if(!(path.isDirectory()))
                   node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
                   else
                   node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
                   node.add(new DefaultMutableTreeNode(new FileInfo(null,"<EMPTY FOLDER>")));
              catch (Exception e)
              return node;
         }

  • Folder Chooser reference (which uses a tree for selection)

    is there a recommendation for a folder chooser which uses a tree for selection? all i've found so far are either:
    * 3rd party folder choosers
    * the file open dialog box of java where you use setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);
    i can't believe there is currently no folder chooser which uses a tree for selection in standard java. so probably i didn't find it. before i write my own, i thought i'd ask.
    thanks for the help!

    No, it doesn't exist in the standard Java API. What's wrong with third party solutions, especially when some of them are open source? Google found quite a few.
    db

  • I'm confused about buying used smart cases for iPad mini 1, 2, and 3.

    I'm trying to buy used smart covers for the iPad mini 1, 2, and 3 but I'm not sure which smart cover versions will fit which mini.
    So far, in pink, I've been able to find MGNN2ZM/A and MF061ZM/A. But I want all the other colors too.
    MacMall.com says MGNN2ZM/A is compatible with iPad mini 1, 2, and 3 and MF061ZM/A is compatible with iPad mini 1 and 2. (Apple doesn't provide the part numbers on their web page)
    Basically, I could really use a list of iPad mini, iPad and iPad Air accessories' parts numbers,  and the device/cover compatibilities, if such a list exists.
    Eventually, I want to buy smart covers in every color for iPad 1, 2, 3, 4, 5 (Air), and 6 (Air 2).
    Thank you for your help in advance ^^

        Hello there ctemple,
    That is a great question, thank you for taking the time to contact us. I am sorry to hear your phone is on it's last leg and not working as it should be. I know how important it is to have a working device at all times so will be more than happy to assist you today.
    Great news on our Verizon Edge program you can upgrade to pretty much any phone in our lineup. You pay a small installment every month over a 24-month span on your bill instead of paying full retail or the two-year pricing all at once.
    If you like you can view additional information about our Edge program by going to http://vz.to/1kqnEzS
    Please let us know if you have additonal questions or concerns. Have a great day!
    KarenC_VZW
    Follow us on twitter @VZWSupport

  • About to use my friggin tree for firewood  :o(

    I was wondering if someone could maybe clue me into a problem that I am having with my DefaultMutableTree. See, I call a recursive method to get the file system of the computer, which is what is added to the tree. So the user is looking at a tree structure of the file system of their computer. My problem is that when I compile and run my program the tree shows up fine, with no hitches. I have given my code to other friends, and for some of them it does not show up, and throws a null pointer exception at the internal interface of this recursive method. I was wondering what might be causing this? My friends that have problems with the code are running either WIN XP, or Mac OS 10.1.4. Here is the code for the initialization of the tree (This will look ugly on the post, so I would hope that you would take the time to copy and paste this into your editor :D)
    //code start.
    import java.io.*;
    import java.io.File;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.beans.*;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.tree.TreeSelectionModel;
    public class File_Encryptor extends JFrame {
    private JFrame thisFrame = this;
    private JTree tree;
    private JMenuBar jMenuBar1 = new JMenuBar();
    private JMenuItem menuOpen = new JMenuItem("Open");
    private JMenuItem menuSave = new JMenuItem("Save");
    private JMenuItem menuClose = new JMenuItem("Close");
    private JMenuItem menuQuit = new JMenuItem("Quit");
    private JMenuItem menuAbout = new JMenuItem("About this software...");
    private JMenuItem menuAdd = new JMenuItem("Add key and user");
    private JMenuItem menuChange = new JMenuItem("Change buddy key");
    private JMenuItem menuSend = new JMenuItem("Send your buddy key");
    private JMenuItem menuDelete = new JMenuItem("Delete selected buddy key");
    private JMenuItem menuReset = new JMenuItem("Reset your key");
    private JMenuItem menuChangeLogin = new JMenuItem("Change Login");
    private JMenuItem menuHelp = new JMenuItem("Help...");
    private JButton openDir = new JButton("Open path");
    private JTextField jTextField1 = new JTextField();
    private JScrollPane treeView;
    private JScrollPane imageView;
    private JScrollPane textView;
    private String ROOT;
    private File root;
    private DefaultMutableTreeNode top;
    final private DefaultMutableTreeNode FILLER = new DefaultMutableTreeNode(new FileInfo ("about:blank", "about:blank"));
    public File_Encryptor() throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
    super("FILE ENCRYPTOR 1.0");
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    ROOT = getRoot(System.getProperty("user.home"));
    root = new File(ROOT);
    try{
    //Create the nodes.
    top = unfold(root);
    top.setUserObject(new FileInfo(ROOT,ROOT));
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode
    (TreeSelectionModel.SINGLE_TREE_SELECTION);
    Object nodage = top.getNextNode().getUserObject();
    FileInfo leaf = (FileInfo) nodage;
    tree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
    tree.getLastSelectedPathComponent();
    if (node == null) return;
    try{
    Object nodeInfo = node.getUserObject();
    FileInfo temp = (FileInfo) nodeInfo;
    if((node.isLeaf()) && (!(node.isRoot())))
    System.out.println(temp.Path());
    //figure out how to place file in editor pane.
    else
    return;
    catch(Exception fubar)
    fubar.printStackTrace();
    treeView = new JScrollPane(tree);
    treeView.setSize(150,450);
    jTextField1.setMaximumSize(new Dimension(50, 100));
    jTextField1.setText("PATH");
    this.getContentPane().add(jTextField1, BorderLayout.EAST);
    this.getContentPane().add(treeView, BorderLayout.WEST);
    catch(Exception e) {
    e.printStackTrace();
    jMenuBar1.setBorder(BorderFactory.createEtchedBorder());
    JMenu menu = new JMenu("File");
    JMenu about = new JMenu("Help");
    JMenu keys = new JMenu("Keys");
    JMenu change = new JMenu("Login");
    menuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.META_MASK));
    menuQuit.setEnabled(true);
    menuQuit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    menu.add(menuQuit);
    jMenuBar1.add(menu);
    jMenuBar1.add(keys);
    jMenuBar1.add(change);
    jMenuBar1.add(about);
    this.setJMenuBar(jMenuBar1);
    public class FileInfo {
    private String path = "";
    private String name = "";
    public FileInfo(String p , String n){
    path = p;
    name = n;
    public String toString(){
    return name;
    public String Path(){
    return path;
    public static String getFileEx(String po){
    String ext = "";
    int i = po.lastIndexOf('.');
    if(i > 0)
    ext = po.substring(i-1);
    else
    ext = null;
    return ext;
    private DefaultMutableTreeNode unfold(File path) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("");
    Vector Files = new Vector();
    Vector Direc = new Vector();
    if((path.isDirectory()) && (path.list().length != 0))
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    File [] childs = path.listFiles();
    for(int j = 0; j < childs.length; j++)
    if(childs[j].isDirectory())
    Direc.addElement(childs[j]);
    else
    Files.addElement(childs[j]);
    for(int g = 0; g < Files.size(); g++)
    Direc.addElement((File)Files.elementAt(g));
    for(int i = 0; i < Direc.size(); i++)
    node.add(unfold((File)Direc.elementAt(i)));
    else if(!(path.isDirectory()))
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    else
    node = new DefaultMutableTreeNode(new FileInfo(path.getPath(),path.getName()));
    node.add(new DefaultMutableTreeNode(new FileInfo(null,"<EMPTY FOLDER>")));
    return node;
    public static String getRoot(String path)
    int find = path.indexOf(System.getProperty("file.separator"));
    String root = path.substring(0,find + 1);
    return root;
    public static void main( String [ ] args )throws FileNotFoundException, InterruptedException, IOException, ClassNotFoundException {
    File_Encryptor show = new File_Encryptor();
    show.setSize(700, 500);
    show.setResizable(false);
    //show.setLocation(100,100);
    show.setVisible(true);
    //code end.
    //well there it is. Hope someone can help me with my problem.
    //I know this code is ugly, but I was trying a bunch of different
    //things hoping something would work. but ehh no such luck.
    //I am running windows 98, yea that's prolly my problem.
    //thank you for your time.

    So you consider this exact post appropriate for both the Advanced Language Topics and New to Java Technology? Did you post this question anywhere else? Don't double post.
    Anyway, check the post in NtJT. The answer is there.

  • Send mail using ALV tree(for excel file) outlook

    Hello Gurus!!!
    The code is as follows :-
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        FILENAME                        = 'C:\exceldown\tree2.xls'
       FILETYPE                        = 'ASC'
      APPEND                          = ' '
       WRITE_FIELD_SEPARATOR           = 'X'
      TABLES
        DATA_TAB                        = lt_project.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CREATE OBJECT outlook 'Outlook.Application'.
    CALL METHOD OF outlook 'CREATEITEM' = outmail EXPORTING #1 = 0.
    SET PROPERTY OF outmail 'TO' = '[email protected]'.
    SET PROPERTY OF outmail 'SUBJECT' = 'Project Management'.
    SET PROPERTY OF outmail 'BODY' =  'This is excel attachment'.
    *SET PROPERTY OF outmail 'Insert File' = 'C:\exceldown\tree2.xls'.
    <b>CALL METHOD OF outmail 'Insert File'.   <b>****NOT WORKING</b>
    SET PROPERTY OF outmail 'Attach' = 'C:\exceldown\tree2.xls'.</b>
    CALL METHOD OF outmail 'SEND'.
    FREE OBJECT outlook.
    Kindly suggest your answers.
    Helpful points will be rewarded
    Thanks,
    Sachin.

    Achieved the requirement using FM RS_TREE_CONSTRUCT

  • My ipad2 was set up with my apple id, i restored it and asked my apple id and password to set it up but i havent used that id for a long time i forgot everything about it what should i do?

    My ipad2 was set up with my apple id, i restored it and asked my apple id and password to set it up but i havent used that id for a long time i forgot everything about it what should i do? And i promise to my dead body i didnt steal my ipad it was a bday gift from my mom... Can anybody help me?

    If you at least know your Apple ID you can go to this Apple Support page.
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    Click on Forgot My Password.
    Try to recover or set a new password. Hopefully your email addresses still get mail from Apple.

  • Hello , I want to ask some question about ipads \  How powerful is the iPad?  How useful is it for reading books, newspaper or magazines or for surfing the web? Can you identify any shortcomings of the device?   please help me :(

    Hello ,
    I want to ask some question about ipads \
    How powerful is the iPad? 
    How useful is it for reading books, newspaper or magazines or for surfing the web?
    Can you identify any shortcomings of the device?  
    please help me

    it's less powerful than your average computer. THink of it like a netbook but with a better processor.
    It'll do fine for surfing (although if you browse a lot of flash based sites you will need to get a third party browser since safari doesn't accommodate it)
    You may do OK on reading books, papers or magazines, especially if they have apps, but the ipad's screen is backlit, so it doesn't work well outdoors and you may need to fiddle with the brightness so that you don't get eye strain (it's just like doing too much reading from a computer screen)
    I would say the biggest short comings are data transfer. Apple's preferred work flow is that everything is done via iTunes or the internet....well people dont' always have 100% reliable always on internet access so you can find yourself in a situation where you can't get things on/off the iPad.
    By and large, it's a good device for day to day stuff, but is not a computer replacement.

  • Since updating to LR5.5 it crashes about every 5-10 images while working in the development module. Computer is PC Windows 7 Home Premium. I have been using this computer for several years with zero problems. Is this related to the updating? What is the f

    Since updating to LR5.5 it crashes about every 5-10 images while working in the development module. Computer is PC Windows 7 Home Premium. I have been using this computer for several years with zero problems. Is this related to the updating? What is the fix?

    Do you get an error message? If so, what does it say?
    Do you get a Blue Screen?
    Does something else happen?

  • I Use the last FCX but  I have a prob when I export (share) to dvd the result is over 4GB for a single DVD is about 6 to 9 Gb for a short film of 1h so what can I do to fix this

    I Use the last FCX but  I have a prob when I export (share) to dvd the result is over 4GB for a single DVD is about 6 to 9 Gb for a short film of 1h so what can I do to fix this thnks

    These "Share" files are accessed and used by the Create Disc app.
    Create Disc is buried in the FCP X package.
    Applications>FCP X>Show Package Contents>Contents>Plugins>Compressor>Compressor Kit.bundle>Show Package Contents>Embedded Apps>Create Disc
    I'm wondering if having the Compressor Application on a Mac makes a difference to having just FCP X on a Mac and the use of the Sharing feature.
    I have Compressor loaded and find that DVD and Bluray burns from Share without any glitches as some are experiencing.
    Al

  • My macbook from 2008 which I bought used worked fine for 3 weeks and then suddenly it started restarting and now it restarts, goes to grey apple screen and a code saying something about a kernel panic appears and it restarts again and again. Help?

    My macbook from 2008 which I bought used worked fine for 3 weeks and then suddenly it started restarting and now it restarts, goes to grey apple screen and a code saying something about a kernel panic appears and it restarts again and again. Help?

    Restart the computer and immediately hold the Option key down.
    Select the Recovery partition and continue.
    On the next pane, select Disk Utility and continue.
    When DU opens, select your hard drive in the left column, click the First Aid tab, the click Repair Disk.
    When that is done, quit DU and restart in the usual way.

  • Use external image for tree icons

    Hi all,
       having searched extensively with probably the wrong keywords, i'm hoping someone can point me in the right direction.
    My app has a tree control that gets built by reading an Ini file, the icons get populated with custom images from a directory.  I'm trying to find a way to be able to interchange those icons after the executable has been built.  The current way that i put the icons in the tree is simplistic.  the names determine where in the tree they go... i.e. icon_1.jpg , icon_2.jpg , icon_3.jpg ...  become the first, second, and third icon.
    i just don't want to have to rebuild the app every time a customer wants to replace the icons. 
    any tips?  
    thanks in advance! 

    I'm not very original,  I'm using a tree toolkit i found on LAVA written by Norm Kirchner. http://lavag.org/index.php?app=downloads&showfile=27
    and a library i found on NI :  http://digital.ni.com/public.nsf/allkb/89A75D98771F2FB686256F350055EB3A
    See the .zip at the bottom of the page, it has an example vi.
    It does in fact use the "Read JPeg File" vi's.
    You'll see in the "Load Symbols.vi" that it takes as input, a directory where your custom symbols are located.  Is there a way to keep this directory outside of the executable when the application builder compiles everything together....????   Like maybe in the /data directory?
    I've only been using the app builder for a couple weeks so I'm not that sharp on those little nuances, but the more we hash this out, it seems like it should be possible.
    Message Edited by joshuatree on 12-07-2009 11:18 AM

  • HT4623 help! I didn't use my ipad for about a month then now it would not turn on, just a balck screen with apple logo blinking in the middle, please help

    Help me. I did not use my ipad for about a month.Now that I turned it on after trying to charge it for many hours, it just would not turn on, just a black screen with sometimes an apple logo blinking, brought it to repair shops, said they could not fix it, please help

    The terms of service of the Apple Support Communities prevent us from helping anyone with a jailbroken phone.
    You're on your own.  Good luck.

  • HT201269 I used Version : 4.2.1 (8C148)  but I want to update New version because some application need 4.3  ....  please tell me about to  update new version for my iPhonoue 4. Thank you.

    I used Version : 4.2.1 (8C148)  but I want to update New version because some application need 4.3 or 5 ....  please tell me about to  update new version for my iPhonoue 4. Thank you.

    Start iTunes on the computer you normally sync with. Connect your phone. Select your phone in iTunes on your computer and select the General tab in iTunes. Then scroll down to check for updates. iTunes will update your phone to the latest version of the iOS that is availablele.

  • I have been using airplay speakers for about 18 months successfully and I now find that it has a locked symbol and not always obtainable

    I have been using airplay speakers for about 18 months sucessfully and now find it has a locked symbol and isn't always available

    I have been using airplay speakers for about 18 months sucessfully and now find it has a locked symbol and isn't always available

Maybe you are looking for

  • Phase MAIN_SHDRUN/ACT_UPG - SAPA741EPU

    Hi, I am making an upgrade from ERP 6.0 EhP 5 to ERP 6.0 EhP 7 I am facing an error message during phase MAIN_SHDRUN/ACT_UPG. The ACTUPG.ELG log file Looks like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DDIC ACTIV

  • How do I open a postscript file, like I open an excel file?

    I'm trying to open a file that I saved as a .ps. I want to open it in the same maner as I open an excel file?

  • DB Update from BAPI

    Hi All, I am trying to create a RFC FM ( BAPI) which will be called from external system. The role of this FM is insert to 3 different  Z tables.  Table structure's  is like Header, Details & Sub details. Requirement is if the insert/update fails on

  • Ordering In Castor

    I was wondering how i would change the order of my xml fields using castor? What kinds of things affect the order in which they appear? From: <?xml version="1.0" encoding="UTF-8"?> <XMLMessage> <DESCRIPTION>How do I access my payroll information</DES

  • Renders Takes Ages A 15 min Video 720p takes 6 hours

    Well, I tried to render a 15 min video with Adobe Media Encoder and it took 6 hours, i have rendered 720p videos before and it worked and it didnt take 6 hours Can someone please help me Heres the AME Encoding log - Source File: G:\AE PROJECTS\Nathan