I search for a method, which gets called if the jpanel is shown on the display, because i have to fetch the real size of the panel.
Any suggestions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have you tried adding a ComponentListener to the JPanel? That would be where I would start with my code in the
componentShown(...)method. For this to work, I think that you must callsetVisible(true)on the JPanel after adding it to the display.The other option is to simply query its size after calling
pack(), orsetVisible(true)on your GUI.Edit
You state:
If you want to know the size of a component held by a window “when the window pops up”, then add a WindowListener to the window and check the size of the component from the
windowOpened(...)method.Edit 2
Then you state:
One Solution: Better not to set the sizes of anything but instead to use the right combination of layout managers and then let them set the proper sizes based on their rules.