I have a set of vertically ordered elements. They are displayed with the following code:
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);
I would like to put a horizontal line between my elements (something like <hr>
in html). Does anybody know how it can be done?
Use a JSeparator. Check out this tutorial on it.
But for a quick answer, just use the following code:
myPanel.add(button);
myPanel.add(new JSeparator());
myPanel.add(label);
Create a JSeparator and add it between button and label.
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