Originally posted by Ted Smyth:
X & Y are container-relative positions (correct me if I'm wrong here, the javadocs mention this being relative to "the parent" of the component) of the top-left corner, if you want to use the size of the components to change the size of dialog, you would be correct in using getWidth() and getHeight().
You could then subtract those values from the width or height (depending on their position) of the dialog (getSize()) to resize it.
Seems like a complicated solution to me though... perhaps with more information about your dialog & problem I could suggest a better solution.
Thanks for your reply.
To be in breif, I have JDialog. There are some fields which should be displayed depending on some input read from a file. What I am doing is simply having all fields on JDialog and setting not required fields to invisible. I had used dialog.pack() to resize before, but still it left some spaces. So I thought of using getHeight() for the last field displayed and setting the size of the JDialog.
I will refer some layout manager tutorials parallely. If you have some better idea, let me know.
regards,
Praveen