想要自定义JTabbedPane的标签栏,关键调用setTabComponentAt(int index,Component component)方法.
在调用JTabbedPane的add(Component component,int index)后立即调用setTabComponentAt方法即可.
代码片段:
public void addCloseComponent(String title, Component component) {
add(title,component);
setTabComponentAt(indexOfComponent(component),new ButtonPanel(this));
}
效果图:
本文介绍如何通过调用setTabComponentAt()方法来自定义JTabbedPane的标签栏,提供了代码示例并展示效果。
5万+

被折叠的 条评论
为什么被折叠?



