可以, 自己写一个 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); 就行了
private static int TAB_HEIGHT_OFFSET = 10; _tabPnl.setUIInvoke(new BasicTabbedPaneUI() { public int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) { return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + TAB_HEIGHT_OFFSET; } }); _tabPnl.updateUI();
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); 就行了
_tabPnl.setUIInvoke(new BasicTabbedPaneUI()
{
public int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
{
return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + TAB_HEIGHT_OFFSET;
}
});
_tabPnl.updateUI();