Albee
Albee

Reputation: 155

java swing jpanel display when clicking a button

i'm new to swing. i've created a jpanel form using the swing palette design. It has jlabels, jtextfields and a jbutton. when the button is clicked, the data entered in the jtextfields is inserted in the database through the model.

i don't want the the jpanel to be always displayed so i would like to add another button that displays this jpanel form when i click on it. is it possible to perform this using the palette design knowing that the source code is locked in the initComponent private function, or do i have to re-code all the components and layout myself?

thanks for your time!

Upvotes: 0

Views: 397

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 208994

"knowing that the source code is locked in the initComponent private function"

You can edit the auto-generated source code, as see here in this answer.

"that displays this jpanel form when i click on it. is it possible to perform this using the palette design"

Sounds like you want to swap views. You can do that using CardLayout and yes, it can be done from the design view. You can see more at How to Use CardLayout with Netbeans GUI Builder

Upvotes: 1

Related Questions