Resizing Leaving Extra Room

    Leaving extra room around the bars in the applet at Resizing fails using GridBagLayout results in different behavior of the applet.  The results depend on the amount of extra room left.  The applet show on this page leaves an extra 10 pixels of space around each component compared to the applet at Resizing fails using GridBagLayout.  Specifically, the line in setBounds:
int barsToShow = height/(barHeight + pad + pad);
is changed to:
int barsToShow = height/(barHeight + pad + pad + 10);
to add extra room around the bars.  With this change, the number of bars can be reduced one at a time until 2 bars are left, after which no further reduction can be made.  

    The behavior of the applet for several values other than 10 is summarized in the table.  The table also includes a solution in which getMinimumSize of the Frame is overridden allowing resizing to work properly, as well as the Resizing using FlowLayout which works in a reasonable fashion:

Behavior as the Frame is resized Layout Extra room parameter
     
One bar at a time is removed until one full bar is left GridBagLayout 15
One bar at a time is removed until 2 full bars are left GridBagLayout 8, 9, 10 (applet here)
One bar at a time is removed until 3 full bars are left GridBagLayout 6, 7
Stays at 4 bars GridBagLayout 0 (applet at Resizing fails using GridBagLayout), 5
Resize down to size specified in getMinimumSize GridBagLayout All
No limit to resizing, can even go below one bar FlowLayout 0 and no pads (applet at Resizing using FlowLayout)

    The source code for the applet on this page can be downloaded from this link.