2011-11-17 29 views
4

我缺少的標籤,並在雨雲L中的內容之間的藍色水平分隔&˚F的TabbedPane設定爲SCROLL(其它L. & FS(默認&窗口)提供的)。雨雲L&F在JTabbedPane的缺失分壓器設置滾動

enter image description here

正如你所看到的問題僅限於new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT)(圖片上部),同時與WRAP默認不顯示這種行爲(圖片的底部)。

應該可以通過覆蓋部分NimbusDefaults.class來改變這種情況。下面是摘錄:

//Initialize TabbedPane 
    d.put("TabbedPane.contentMargins", new InsetsUIResource(0, 0, 0, 0)); 
    d.put("TabbedPane.tabAreaStatesMatchSelectedTab", Boolean.TRUE); 
    d.put("TabbedPane.nudgeSelectedLabel", Boolean.FALSE); 
    d.put("TabbedPane.tabRunOverlay", new Integer(2)); 
    d.put("TabbedPane.tabOverlap", new Integer(-1)); 
    d.put("TabbedPane.extendTabsToBase", Boolean.TRUE); 
    d.put("TabbedPane.useBasicArrows", Boolean.TRUE); 
    addColor(d, "TabbedPane.shadow", "nimbusDisabledText", 0.0f, 0.0f, 0.0f, 0); 
    addColor(d, "TabbedPane.darkShadow", "text", 0.0f, 0.0f, 0.0f, 0); 
    ... more ... 

我似乎無法弄清楚在何處以及如何被雨雲WRAP & SCROLL區分。有人可以告訴我,我有什麼神奇的.put()去那裏?

在此先感謝!

+0

+1可以請你提供這個問題的答案http://stackoverflow.com/q/7481991/714968 – mKorbel

+0

感謝您的信任,但我是誰不知道如何做到這一點。我看了一下,但沒有發現任何問題。試圖解決此問題的人可能會從您在問題中發佈的SSCCE中受益。謝謝! – Omphaloskopie

回答

1

可能關注的人:

一位同事找到了問題的根源。在:

package javax.swing.plaf.synth.SynthTabbedPaneUI; 

它說:

protected void paint(SynthContext context, Graphics g) { 
    int selectedIndex = tabPane.getSelectedIndex(); 
    int tabPlacement = tabPane.getTabPlacement(); 

    ensureCurrentLayout(); 

// Paint tab area 
// If scrollable tabs are enabled, the tab area will be 
// painted by the scrollable tab panel instead. 
// 
if (!scrollableTabLayoutEnabled()) { // WRAP_TAB_LAYOUT 

     [...] 

     // Here is code calculating the content border 

     [...] 

    } 

    // Paint content border 
    paintContentBorder(tabContentContext, g, tabPlacement, selectedIndex); 
} 

正如你可以看到scrollableTabLayout被排除在此計算分隔條的大小下面的代碼。當你按照你所看到的方括號:它後來被繪了,但錯誤的參數。這導致如果選項卡設置爲內容的TOP或LEFT,則省略分隔符的行爲。如果設置爲RIGHT或BOTTOM,實際上顯示的是分隔符,但是被打破(邊框朝向內容太厚,總體上不夠長)。

從Synth到Nimbus都會花費一些時間, 。很多最終和包保護類

因此,你可能想省事:

uiDefaults.put("TabbedPane:TabbedPaneTabArea.contentMargins", new InsetsUIResource(3, 10, 0, 10));  

這將去掉下部差距縮小到你的標籤,你可以將一個「假」分水嶺上儘管如此,我們處理它的方式也是如此,

希望它有幫助。請享用!

+0

如果有人提出了一個更好/更簡單的解決方案,我將切換「正確答案」 - 標誌。 – Omphaloskopie