Java – nimbus L & F is missing the delimiter on jtabbedpane and is set to scroll

I missed the blue horizontal separation line between the labels and the content set as scroll in nimbus L & F tabbedpane (these are provided by other L & fs (default & window))

As you can see, the problem is limited to the new jtabbedpane (jtabbedpane. Top, jtabbedpane. Scroll_tab_layout) (at the top of the picture), while wrap's default setting does not show this behavior (at the bottom of the picture)

It should be possible to override nimbusdefaults Class to change such things This is an excerpt:

//Initialize TabbedPane
    d.put("TabbedPane.contentMargins",new InsetsUIResource(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);
    addColor(d,"TabbedPane.darkShadow","text",0);
    ... more ...

I can't seem to figure out where nimbus is and how to distinguish Wrap & scroll Someone can tell me what magic I have Put () get there?

Thank you in advance!

Solution

Dear Sirs

A colleague found the root of the problem At:

package javax.swing.plaf.synth.SynthTabbedPaneUI;

It says:

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);
}

As you can see, scrollabletablayout is excluded from the following code, where the separator size is calculated When you follow the parentheses you see: it will be drawn later, but there are wrong parameters If the tab is set to top or left of the content, it will cause the behavior of omitting the separator If it is set to right or bottom, the separator will actually be displayed, but it will be damaged (the border is too thick towards the content and is not long enough on the whole)

Covering everything from synth to nimbus requires a lot of effort, because there are many final versions and package protected classes

Therefore, you may want to take a simpler approach:

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

This will strip the lower gap to your label, and you may place a "fake" separator on the top edge of the content panel But that's how we deal with it

I hope I can help you Please enjoy!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>