I have created to GUI interfaces using netbeans drag n drop. The first interface has a button upon clicking which opens the second interface. I want to close the 1st interface as soon as I click the button in it so that only the second interface is displayed.
How can I do that?

Recommended Answers

All 5 Replies

Just setVisible(false) /* temporary */ or dispose() /* permanent */ the first window in the button's ActionListener

James was faster...

BTW why you messing with drap and drop if you do not know basics? Your teacher will easily discover you used IDE to create application and you may loose marks because of it...

Thanks for the reply.. I was calling the class directly and hence the setVisible operation did not appear in the Action listener function. I made an object and den i was able to close it.

@peter: this was not for my assignment and didnt have any marks..

Just do something like that:

cmdEnter.addActionListener(new ActionListener() 
	{
       
    		public void actionPerformed(ActionEvent e)
    		{
    		    dispose();             //closes current Panel	
                    new frmPanel2().show();  //opens next Panel
    				
    		}	
    		
    });

Thanks for the help!:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.