LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java JFrame and JPanel listener (https://www.linuxquestions.org/questions/programming-9/java-jframe-and-jpanel-listener-736808/)

hunterfighter 06-30-2009 06:59 PM

Java JFrame and JPanel listener
 
Hi,

Currently, I am doing a program. I will have few JPanel and only one JFrame.

By default, JFrame will show a JPanel (Panel A), in full screen.

I implement a button in Panel A to call the Panel B.

How am I to realize this coding?

Panel A will be either remove or disappear from the JFrame and add Panel B into the JFrame.

Thank you

kellinwood 06-30-2009 09:44 PM

Add both panels to the JFrame. In the event handler for the button click, call panelA.setVisible( false); and panelB.setVisible(true);

hunterfighter 06-30-2009 10:05 PM

The listener is on JFrame or JPanel?

kellinwood 07-01-2009 09:28 AM

from the listener attached to the button via button.addActionListener( listener);

Ken


All times are GMT -5. The time now is 11:08 PM.