Java Swing implementation tab function (jtabbedpane) example code

Swing implements tab function (jtabbedpane)

First create a jtabbedpane object. The constructor can use jtabbedpane (int tabplacement). Tabplacement is the jtabbedpane slave interface javax swing. Field inherited by swingconstants. It can be button, top, etc. The following code is shown:

Call the addtab function to add information to the tab. There are also several addtabs, of which void addtab (string title, component component) is simply used, so that the tab can have a title, and the information component is added to this tab. Generally, the component is a panel. Put a designed panel in this tab. The following code is shown:

After adding the code, you can select which tab is displayed by default, and use setselectedindex (int index). If I select the first tab, I use the following code:

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>