In a GridBagLayout, what component is the best for providing empty space in a panel? Ideally I would like to use a component that has:
- Low overhead
- No side effect when no empty space is required (i.e. no minimum size)
- A trivial constructor (no parameters)
A JPanel violates #2 above. A Box requires a constructor parameter (#3 above), which is really not necessary in this simple case. A JLabel works well but I worry that it may have some overhead, though admittedly it is probably pretty low.
An anonymous class also seems to work well (i.e. "new JComponent() { }"), but that adds an additional .class file every time I use it. I suppose it's no more overhead than any given event handler though. Would it be worth creating a custom, zero-implementation component derived from JComponent for this? Is there an existing component that I am missing?
FYI GridBagLayout is one of my constraints on the team I'm part of, so other layouts are not an option.