Is there an equivalent in Java for fieldset (HTML)?

不问归期 提交于 2019-12-05 12:00:19

问题


Is there an element in Java (i.e. Swing/AWT or SWT) that is equivalent to the HTML element fieldset?


回答1:


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")); 



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/10820724/is-there-an-equivalent-in-java-for-fieldset-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!