setting horizontal and vertical margins
Don't know html, so just guessing on possible equivalents :-)
- to set some space between a component's bounding rectangle and its content, the property to set is its Border
- the spacing between the different components in a container is controlled by the LayoutManager (already mentioned). Depends on the concrete implementation how fine-grained that's configurable
setBorder(BorderFactory.createEmptyBorder(int top, int left, int bottom, int right));
And for more details you can read the documentation about BorderFactory