Reputation: 1120
I am facing problem during event handling.
The problem is like this:
mainPanel
(JPanel) which in turn consists of a panel with three buttons (namely btn1
, btn2
, btn3
) at its WEST position.pnl1
, pnl2
, pnl3
(each panel has one label and one text area) using three different functions of same class.btn1
/ btn2
/ btn3
then pnl1
/ pnl2
/ pnl3
respectively must appear at mainPanel
's CENTER position.Upvotes: 0
Views: 78
Reputation: 7256
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.
Upvotes: 2
Reputation: 36601
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
Upvotes: 2