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