Is there an element in Java (i.e. Swing/AWT or SWT) that is equivalent to the HTML element fieldset
?
Have a look at javax.swing.border.TitledBorder
. You can set them on panels and are similar in appearance to HTML fieldsets.
Border titleBorder = new TitledBorder(new LineBorder(Color.RED), "Fieldset");
You could then add the border to your panel using the setBorder()
method.
If you are using SWT than I think that org.eclipse.swt.widgets.Group
is what you are looking for. It is a Composite
(a block in HTML analogy) and it looks like a fieldset in HTML.
I can't speak for AWT and SWING however.
Create a Panel, create a titled border and you will be able to put inside all your field components.
JPanel panel = new JPanel();
panel.add(new JLabel("foo"));
panel.setBorder(BorderFactory.createTitledBorder("bar"));