ActionListener ruft Funtion auf -> Fehler

Layna

Erfahrenes Mitglied
OOOK, ich habe ein Problem das ich leider ganz und Gar nicht zurückverfolgen kann (Problem KÖNNTE von swing kommen, ich bin aber ncith sicher, daher hier).
Ich habe:
Eine Klasse die ein Fenster baut.
Die JMenuBar habe ich ausgelagert:
Code:
public class MainMenuBar extends JMenuBar implements ActionListener

mit folgendem Construktor:
Code:
	public MainMenuBar(StartWindow parentWindow) {
		super();
		
		parentWindow = this.parentWindow;

//Menupunkt "Programm"
		JMenu prog = new JMenu("Programm");
		this.add(prog);	
		
		JMenuItem progEnde = new JMenuItem("Beenden");
		prog.add(progEnde);
		progEnde.addActionListener(this);
                (....)
	}



Es folgen noch eine menüs und menüitems.
parentWindow ist eine Klasse, die eine JFrame erstellt und anzeigt (DAS funktionier) und zur Zeit folgende weitere Funktion hat:
Code:
		public void changeContent(JComponent newComponent){
			this.myMainWindow.getContentPane().removeAll();
			this.myMainWindow.getContentPane().add(newComponent);
			this.myMainWindow.pack();
			this.myMainWindow.show();
		}

Auch diese Funktion funktioniert.
Wenn ich diese Funktion jetzt aber über den ActionListener der MenuBar aufgerufen wurd:
Code:
	public void actionPerformed(ActionEvent e) {
		JLabel test = new JLabel("Test33");
		this.parentWindow.changeContent(test);
	}

Kommt folgender Fehler:
Code:
java.lang.NullPointerException
	at activeCompetition.swingComp.MainMenuBar.actionPerformed(MainMenuBar.java:102)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.AbstractButton.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
	at java.awt.Component.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.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

Soo, ich hoffe das macht erstens soweit Sinn und zweitens das jemand weiss WAS da eigentlich los ist.
 
*seuft*
Leute.. vergesst es... BLÖDER BLÖDER fehler:
parentWindow = this.parentWindow;
Das ist SOWAS von verkehrt herum... naja, ich habs gefunden.. weiss nur nciht warum ich es sorum geschrieben habe....
 
Zurück