I have code like that:
JPanel myPanel = new JPanel();
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));
JButton button = new JButton("My Button");
JLabel label = new JLabel("My label!!!!!!!!!!!");
myPanel.add(button);
myPanel.add(label);
In this way I get elements with no distance between them. I mean, the "top" elements always touches the "bottom" element. How can I change it? I would like to have some separation between my elements?
I think about adding some "intermediate" JPanel (with some size) between my elements. But I do not think it is an elegant way to get the desired effect. Can somebody, pleas, help me with that?