I have only JTabbedPane inside JFrame. JTabbedPane sets its dimensions to biggest page width/height. As pages has different size is it possible to force JTabbedPane to change its dimensions when selecting other page?
Top one is how it behave now and bottom one is how i want it to behave (i resized frame by hand)
How about this?
This is fairly simple. It involves dynamic calculation of differences between your pages dimensions and the using them to force preferred size on you
JTabbedPane
. I did a quick experiment and it worked. So instead of putting a lot of text here - here is the code. It is not perfect but you should get an idea. Questions are welcome, of course.I think another option is to dynamically change the panels of each tab when the tab is selected:
JTabbedPane
selectionpack()
on the window/dialog containing theJTabbedPane
Disclaimer: I haven't tested this approach but I believe it should work according to what you want.
Please also note that dynamically changing the size of the dialog based on the selected tab is not very user-friendly from a pure GUI viewpoint.