Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are adding a <code>Box</code> strut to a <code>BoxLayout</code>.</p> <p>As the <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/Box.html#createHorizontalStrut%28int%29" rel="nofollow">javadoc</a> states, <code>createHorizontalStrut(int width)</code>:</p> <blockquote> <p>Creates an invisible, fixed-width component. In a horizontal box, you typically use this method to force a certain amount of space between two components. In a vertical box, you might use this method to force the box to be at least the specified width. The invisible component has no height unless excess space is available, in which case it takes its share of available space, just like any other component that has no maximum height.</p> </blockquote> <p>As such, it is filling the height between your title <code>JLabel</code> and the bottom of the <code>JPanel</code>.</p> <p>You might want to consider using <code>Box.createRigidArea(new Dimension(20, height))</code> instead, where height could be specified or set to the height of <code>labelPanel</code>.</p> <p>Or, you could reconsider the layout for your <code>JPanel</code> - take a look at the <a href="http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html" rel="nofollow">visual guide</a>.</p> <p>For future reference, if you cannot make sense of your Swing layout, try putting adding a coloured <code>LineBorder</code> to the <code>JComponent</code>s you're unsure of. In this case, the <code>Box</code> struts are not <code>JComponent</code>s but <code>Component</code>s, so you'd have to put them into a <code>JPanel</code>, but this would at least have shown you what space each component was taking up in your top-level <code>JPanel</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload