I am facing problem during event handling.
The problem is like this:
- My GUI has
mainPanel(JPanel) which in turn consists of a panel with three buttons (namelybtn1,btn2,btn3) at its WEST position. - I have created 3 more panels namely
pnl1,pnl2,pnl3(each panel has one label and one text area) using three different functions of same class. - My requirement is that if I click
btn1/btn2/btn3thenpnl1/pnl2/pnl3respectively must appear atmainPanel's CENTER position.
3 Answers 3
You will have to add action listener to the btn1, btn2, btn3. Then when the respective button is clicked you write a function that will display the required respective panels to the center of GUI. To do so you can use cardLayout.
If you add detail to your question then we can help you with better answer or suggestions.
What's the purpose of the label and text area? Add a screenshot of your GUI and some code that you have written.
1 Comment
You could consider creating a JPanel with a CardLayout for the CENTER panel. The CardLayout could contain 4 UI's ( the pnl1,pnl2,pnl3 and an empty panel ), and clicking on those buttons could activate the correct panel on the CardLayout