首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

有没有办法设置JtabbedPane的tab(选项卡)的高度和宽度?该如何处理

2012-01-29 
有没有办法设置JtabbedPane的tab(选项卡)的高度和宽度?如题.[解决办法]可以, 自己写一个 YourPaneUI exten

有没有办法设置JtabbedPane的tab(选项卡)的高度和宽度?
如题.

[解决办法]
可以, 自己写一个 YourPaneUI extends BasicTabbedPaneUI

下面2个方法就是画tab的高度和宽度

protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)

比方说
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
return super.calculateTabWidth(tabPlacement, tabIndex, metrics)+80;
}

protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
{
return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight)+80;
}

就画出了大的tab

然后

JTabbedPane yourTabPane = new JTabbedPane();
YourPaneUI yourPaneUI = new YourPaneUI();
youtTabPane.setUI(yourPaneUI);

就行了

热点排行