Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    Okay, so this may be a newbie question (because in reality, that's what I am), but I am receiving this error:

    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at javax.swing.SwingUtilities.computeIntersection(Unknown Source)
    	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    	at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
    	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    When my code (below) throws an IllegalAccessException (It begins to display the JOptionPane, the pane freezes, and never renders. Upon trying to close the window, I receive the above error.

    Java Code:
    	public Color renderStringToColor(String colorString) {
    		if(colorString == null){
    			throw new IllegalArgumentException("Color must be designated.");
    		}
    		
    		Color colorToReturn;
    		Field colorField;
    		
    		try{
    			
    			colorField = Color.class.getField(colorString.toUpperCase().trim());
    			colorToReturn = (Color) colorField.get(null);
    		}
    		catch(NoSuchFieldException nsfe){
    			
    			JOptionPane.showMessageDialog(null, "The declared color is not valid; defaulting to black.", "No Such Field Exception", JOptionPane.ERROR_MESSAGE);
    
    			return Color.BLACK;
    		}
    		catch(IllegalAccessException iae){
    			
    			JOptionPane.showMessageDialog(null, "The current color is unavailable to be used; defaulting to black.", "Illegal Access Exception", JOptionPane.ERROR_MESSAGE);
    			
    			return Color.BLACK;
    		}
    		catch(SecurityException se){
    			
    			JOptionPane.showMessageDialog(null, "Access to declared color denied; defaulting to black.", "Security Exception", JOptionPane.ERROR_MESSAGE);
    			
    			return Color.BLACK;
    		}
    		
    		return colorToReturn;
    	}
    I've looked it up quite a bit, and haven't found anything overly useful. From what I can tell, the error is actually occurring outside my code (seeing as it isn't referenced in the error), I just can't seem to figure out how to solve it. Any help is appreciated. Thanks!

  2. #2
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default

    Just Kidding. I just solved the problem myself.

    I didn't realize that static method calls to JOptionPane were still modal and blocked the EDT.

    Interestingly enough, wrapping the call to JOptionPane within invokeLater() solved the problem.

    Thanks to anyone who took the time to read the above problem. I appreciate the effort.

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2010, 03:19 PM
  2. Replies: 6
    Last Post: 06-06-2010, 09:02 PM
  3. Replies: 0
    Last Post: 05-28-2010, 02:47 PM
  4. Replies: 3
    Last Post: 04-30-2010, 07:44 PM
  5. Replies: 5
    Last Post: 08-26-2009, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •