I have the below code, where I have a JPanel that needs to occupy all the space of the JFrame but stop when the frame completes. When using the Form Layout it does not. Please see the below code
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final JFrame frame=new JFrame();
JPanel panel=new JPanel(new BorderLayout());
FormDebugPanel comp = new FormDebugPanel(
new FormLayout("10dlu,fill:pref:grow,10dlu","10dlu,fill:pref:grow,10dlu"));
panel.add(comp, BorderLayout.CENTER);
frame.setContentPane(panel);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
This results in the diagram below. The border on the right and the bottom does not show, since it looks like the panel continues to grow beyond the parent container's boundary. Is there something that I am doing wrong?
You must either set a preferred size on the frame first or change the grow and fill. pack() only works if you are packing after formdebugpanel loaded its components.