Hello,

I am having some trouble with getting my menu to respond to a mouse click.I have 2 items on my menu, "New" and "Exit", and they are using the actionlistner like so

newFromMenu = new JMenuItem("New Screen");
newFromMenu.addActionListener(this);

and then my action event

public void actionPerformed(ActionEvent e){

if(e.getSource() == newFromMenu ){
			
showPictures.setEnabled(true);
			
b1.setSelected(false);
b2.setSelected(false);

			
resetPanel();
			
panel = createPane();
setContentPane(mainPanel);
		
setVisible(true);
}
}

The code compiles fine, but when I try to run the program I am presented with an error and the Frame will not display.Is it obvious as to what I am doing wrong?

Thanks
Static.

What exactly is the error you are presented with?

It was a null to pointer error. I have overcome the error through creating local actionPerformed event handlers instead of the method shown above and it now works.I think it may have been a problem with a JMenu Item having the same functionality as a button in the JFrame.