I cannot determine how to resize some components in the swing GUI. Some custom labels are added to FlowLayout, which does not behave as it should when resizing a dialog box. A panel is created using the jgoodies form structure.
If you use this, where FlowLayout is added to xy (3, y)
FormLayout layout = new FormLayout("r:d, 5px, f:d:g", // columns "p, p, 5px, p, 5px, p") // rows
Expands FlowLayout and displays a scrollbar
Using
FormLayout layout = new FormLayout("r:d, 5px, f:10:g", // columns "p, p, 5px, p, 5px, p") // rows
FlowLayout uses the available space, and the elements on the second line disappear
I would like to increase the height of each row containing FlowLayout to the current height of the component. Unfortunately, the preferred size always corresponds to the height for one row.
Would a layout be more appropriate? The bold text on the left should be aligned on the right, and then FlowLayout.
Sources
[edit] After you have tried to figure out how to do this in a few weeks, you can resume the urgent question: A set of labels is added to JPanel. This JPanel should use all available spaces horizontally (dialog size minus tag name tag width) and expand vertically as needed. If the JPanel's height becomes larger than the dialog, a vertical scrollbar should appear (the horizontal scrollbar is never visible). A dialog can display several JPanels, which will be displayed one after the other (vertically).
Here's an attempt to use GridBagLayout and WrapLayout :
public class GridBagLayoutTagPanel extends JPanel { private static final long serialVersionUID = -441746014057882848L; private final int NB_TAGS = 5; public GridBagLayoutTagPanel() { setLayout(new GridLayout()); JPanel pTags = new JPanel(new GridBagLayout()); pTags.setBackground(Color.ORANGE); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 5; c.ipady = 5; int rowIndex = 0; for (int i = 0; i < NB_TAGS; i++) {