Possible Duplicate:
Adding a button component to a java tabbed pane in java
是否可以向 JTabbedPane 选项卡(选项卡本身)添加一个按钮,以便单击时可以执行操作,例如关闭选项卡?
最佳答案
当然。首先添加一个像这样的选项卡:
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add( "title", content );
然后用以下内容更改“标题”标签:
tabbedPane.setTabComponentAt( 0, new JButton( "This is now a button!" ) );
// 0 is the tabindex
关于java - 在 JTabbedPane 选项卡内添加 JButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13916651/