Nimbus L & F missing a separator on JTabbedPane set to scroll

I skip the blue horizontal separator between the tabs and the content in the Nimbus L & F TabbedPane set to SCROLL (other L & Fs (by default and windows) provide this data).

enter image description here

As you can see, the problem is limited to new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT) (at the top of the picture), while by default WRAP does not show this behavior (at the bottom of the image).

You should change something like this by overriding the parts of NimbusDefaults.class . Here is an excerpt:

 //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 ... 

I just can't figure out where and how Nimbus distinguishes between WRAP and SCROLL. Can someone please tell me what magic do I need .put() to get there?

Thanks in advance!

+4
source share
1 answer

Who can it relate to:

The employee found the source of the problem. IN:

 package javax.swing.plaf.synth.SynthTabbedPaneUI; 

He 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 divisor size is calculated. As you follow the brackets, you see: it is later drawn nevertheless, but with the wrong parameters. This results in behavior that the separator is omitted if the tabs are set to TOP or LEFT content. If set to “RIGHT” or “BOTTOM”, the division is actually displayed, but breaks (the border with respect to the content is too thick, generally not long enough.

It would take quite a bit to fix everything from Synth to Nimbus, because there are many final and package-protected classes.

Therefore, you may need to simplify the route:

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

This will split the bottom span into your tabs, and you can put a “fake” spacer on the top edge of your content panel. This is how we deal with it.

Hope this helps. Enjoy it!

+1
source

Source: https://habr.com/ru/post/1381678/


All Articles