Forums Register Login

linking two jpanels

+Pie Number of slices to send: Send
i am working a desktop application,in which i am having a jpanel which is a login page,what i want is to move to other jpanel on successful login .
+Pie Number of slices to send: Send
One possible approach would be-
Add the panels to the JFrame- Set the ones not required to Visibility =false
Based on which panel to Hide/Show you can alter the Visibility value accordingly.

For this there's a method- setVisible(boolean). Also check out the Swing tutorial if you want to learn how to use the components.
+Pie Number of slices to send: Send
I don't think playing around with the visibility is a good idea.

Check out CardLayout It helps you switch contents.
In case you want to switch from panel1 to panel2 without using card layout you can call the remove() and add() on the container. Just don't forget to invoke() as well as repaint() to refresh the UI after the remove/add
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:I don't think playing around with the visibility is a good idea.

Check out CardLayout It helps you switch contents.


Actually, CardLayout uses switching invisibility in the background. But I agree that letting it do the hard work is a better idea.

Just don't forget to invoke()


I think you meant invoke revalidate(), right?
+Pie Number of slices to send: Send
 

Rob Prime wrote:

Just don't forget to invoke()


I think you meant invoke revalidate(), right?



Darn. Yes. I meant invoke revalidate() as well as repaint().
Thanks for the catch Rob!
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1202 times.
Similar Threads
Jpanels and Jscrollpanels
complex dialog layout?
Resizing a JButton in GridLayout
Help Regarding JScrollPane embedded in JPanel
using two fonts at time
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:57:01.