简体   繁体   中英

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!

"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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM