Minimum size a bit too small

Hi Beni,

I noticed that the docking framework respects the minimum sizes of the components inside dockables.
I think however some of the insets might not be taken into account which results in the
dockable being sized slightly too small (2 pixels in each direction).
When I run the code below in 1.1.2p2b, resize Red to its minimum size
and press the button, I get:

minimum size java.awt.Dimension[width=211,height=36]
actual size  java.awt.Dimension[width=209,height=34]

I run the following code:

package test;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;

public class Dock58
{
  public static void main(String[] args)
  {
    // setting up frame and controller
    JFrame frame = new JFrame();
    CControl control = new CControl(frame);
    control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(700, 700);

    DefaultSingleCDockable red = create(control, "Red", Color.RED);
    DefaultSingleCDockable green = create(control, "Green", Color.GREEN);
    DefaultSingleCDockable blue = create(control, "Blue", Color.BLUE);

    CGrid grid = new CGrid(control);
    grid.add(0, 0, 10, 10, red);
    grid.add(10, 0, 5, 5, green);
    grid.add(0, 5, 5, 5, blue);

    control.getContentArea().deploy(grid);
    frame.getContentPane().add(control.getContentArea(), BorderLayout.CENTER);
    frame.setVisible(true);
  }

  public static DefaultSingleCDockable create(CControl control, String title, Color color)
  {
    final JPanel panel = new JPanel();
    panel.setOpaque(true);
    panel.setBackground(color);
    JButton b = new JButton("test button with long text on it");
    b.addActionListener(new ActionListener()
    {

      public void actionPerformed(ActionEvent e)
      {
        System.out.println("minimum size " +panel.getMinimumSize());
        System.out.println("actual size  " +panel.getSize());
      }
    });
    panel.add(b);

    final DefaultSingleCDockable singleDockable = new DefaultSingleCDockable(title, title, panel);
    singleDockable.setCloseable(true);

    return singleDockable;
  }

}

kind regards,
Maciej Modelski

Good catch. I’ll start searching for that missing inset…

I’ve uploaded a version that fixes this issue. It really was the insets of the EclipseBorder which were ignored.

It works, thanks! :slight_smile: