Is there an element in Java (i.e. Swing/AWT or SWT) that is equivalent to the HTML element fieldset
?
<fieldset>: The Field Set element. The <fieldset> HTML element is used to group several controls as well as labels ( <label> ) within a web form.
The fieldset element can also contain nested fieldset elements. This is normally only required in complex forms, where there are subgroups of form elements inside larger groupings. In this example, a fieldset for your profile includes a nested fieldset for contact details.
A fieldset is as large as the parent container, just like any block-level element, if you do not give it a fixed width. So you have to make it display: inline-block . Show activity on this post.
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"));
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 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