I'm trying to remove some space on my GUI. Here's a simple example, with a couple buttons in a JPanel with a TitledBorder.
Is there any way to decrease the space between the buttons and the border (especially the top one)?
I'm pretty sure it has something to do with the TitledBorder's insets, but I don't see any obvious way to decrease it.
I don't understand what the getBorderInsets() method does, or what I should pass to it.
Thanks!
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test
{
public static void main (final String[] args)
{
JPanel panel = new JPanel();
panel.setBorder (BorderFactory.createTitledBorder ("Title"));
panel.add (new JButton ("Button 1"));
panel.add (new JButton ("Button 2"));
JFrame frame = new JFrame();
frame.add (panel, BorderLayout.CENTER);
frame.pack();
frame.setVisible (true);
}
}