2

Possible Duplicate:
Adding a button component to a java tabbed pane in java

Is it possible to add a button to a JTabbedPane tab (the tab itself) so that when clicked it could perform an action, for example close the tab?

4

1 回答 1

3

当然。首先添加一个这样的选项卡:

JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add( "title", content );

然后用这个改变“标题”标签:

tabbedPane.setTabComponentAt( 0, new JButton( "This is now a button!" ) );
// 0 is the tabindex
于 2012-12-17T15:14:18.237 回答