954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

pack() for static

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

brothman
Newbie Poster
1 post since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

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.

JamesCherrill
Posting Genius
Moderator
6,370 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: