Hello every body:
I have JPanel with many JButtons inside in one row and I am using flow layout to add them
how to make the panel that contains these buttons dynamically extends vertically when it is being resized horizontally to show the all buttons.
because i tried to do that but the button as I said in one row so when I resize the panel some of them disappear according to new size of the panel
so, would you please let me know how to make these buttons shift to two rows or more in that I need to panel to be extended vertically at the same time I need to keep the panel's size fitted with its components ... I mean
no need to make the panel size bigger then it is needed to hold the whole components.
I think this depends on the layout I tried many but it seems there is still something missing ...
one more important note : below this panel there is another panel so when the top panel is extended vertically the panel that is below it should be shifted to the bottom to give the top panel more space ...
thank you for your help
hello again ..
I added this post to clear what I want to do exactly:
in this application I have mainPanel that includes leftPanel and rightPanel that are separated by splitPane
now the main work is in the rightPanel
I defined GridBagLayout for this panel to organize the items in one columns so this rightPanel will includes subpanels like p1,p2,p3,p4 etc.....
that works well till now
each subpanel includes a button and another panel below that button so also I used GridBagLayout for the subpanel (p1,p2,p3....) to organize their components in one column.
so let say that the subpanel p1 includes button1 and other sub-subpanel pp1
I defined flowlayout for pp1 and added some buttons
the idea here is when I click on button1 this should hide pp1 with its buttons and and the second panel p2 is shifted up to occupy the new available space and when clicking again on button 1 the pp1 should appear again and p2 should be shifted down to give more space for
the p1 after adding pp1 to it. this is explained in photo1 and photo2.
but the problem is when I resize the right panel horizontally I want the panel pp1 to be resized to a size that fits with its components
in other word it should be capable for extending vertically to decrease or increase its height according to the need to make the whole component seen.
photo 3 and 4 show you some
and I attached the code so may some one can help me about solving this problem.
waiting for your response.