1

I have a program with a bunch of fields in a single panel, both labels and text fields. I needed to separate them somehow with a line to make it easier to read.

I have the panel built with SpringLayout. I was wondering if there is an easy way to create a horizontal line in SpringLayout without dividing the panel into 2, and adding a divider panel in between them.

Thanks!

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Caveman42
  • 679
  • 2
  • 13
  • 35

1 Answers1

3

I think the best practice would be creating another JPanel, but if I correctly understood your problem, maybe an alternative can be create a JSeparator:

JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
separator.setPreferredSize(new Dimension(200,3));
elias
  • 15,010
  • 4
  • 40
  • 65
  • Thank you, I tried using JSeparator but nothing was showing up, but I wasn't putting a size on it so I guess the size defaulted to 0? But doing what you said did create a horizontal line the way i needed. Thanks a bunch! :) – Caveman42 Nov 05 '12 at 18:03