AWT EventQueue NPE bei Shape intersect

Helgon

Bekanntes Mitglied
Hey, ka ob ich grad was offensichtliches übersehe, aber hat wer ne Idee warum ich ne NPE geschmissen kriege?

Das Objekt ist definitiv korrekt initialisiert, vorhanden, gefüllt etc.. aber ich krieg trotzdem den error. 😳

Java:
@Override
	public void mouseClicked(MouseEvent e) {
		painter.checkForIntersect(e.getX(), e.getY());
	}

Java:
public boolean checkForIntersect(int posX, int posY){
		
		ArrayList<Shape> temp = (ArrayList<Shape>) paintingComponent.getShapes().clone();
		System.out.println("size: "+temp.size());
		
		for(Shape s : temp){
			if(s.getClass().isInstance(Ellipse2D.class)){
				if(s.contains(posX, posY)){
					return true;
				}
			}
		}
		return false;
	}

Java:
size: 71
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at GraphPainter.checkForIntersect(GraphPainter.java:395)
	at ProbabilityFrameGui.mouseClicked(ProbabilityFrameGui.java:46)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$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)

Vielleicht hat grad wer ne Idee?

Grüße
 
Java:
        for(Shape s : temp){
            System.out.println("Ist das null? "+s);
            if(s.getClass().isInstance(Ellipse2D.class)){
!?
 
Ach kacke, ich hab mir so ne coole methode überlegt alles zu zeichnen, aber vergessen dass die shapes manchmal leer sein können 😛

ich hatte das natürlich auch probiert, und da war auch ein objekt vorhanden, nur das 10te z.b. mal nicht

ahhh wie blöd von mir.

Auf jeden Fall danke :bloed:
 

Zurück
Oben