I use multiple components that has a border painted. Is there any easy way to add a margin to the component so that the borders aren't painted so close to eachother?
Another way to get what you want is to:
Border of your
componentnull, set an EmptyBorder for your
componentnull, create a new
CompoundBorder (with an EmptyBorder
and the current Border of the
component) and set it for the
componentIn code, that should look like that (sorry I haven't tested it):
Border current = component.getBorder();
Border empty = new EmptyBorder(top, left, bottom right);
if (current == null)
{
component.setBorder(empty);
}
else
{
component.setBorder(new CompoundBorder(empty, current));
}
Where:
Note that this method might have an impact (size, alignment) on the form layout, depending on the LayoutManager you are using. But I think it is worth trying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With