Hey... don't know why this is happening... I've probably I've done this or things like itat least a few times before...

public class FileTree
{
public static DisplayWindow window;
   public void refresh()
   {
     DisplayWindow temp = FileTree.window;
     //temp.pack();
   }

      public static void main(String[] Args)
      {
          window = new DisplayWindow(new FileTree(new FileNode(null)));
      }

why does the preceeding code not work? I get a NullPointerException whenever I try to run it uncommented..

Please show the code for DisplayWindow (or at least the constructor that is called on line 12), and the code for the FileTree constructor ditto. If either of those causes (directly or indirectly) a call to refresh() then this will happen before any value is assigned to window on line 12.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.