问题
I'm writing a Swing program using JTabbedPane (containing a JScrollPane) and the Windows look and feel. When the JTabbedPane renders with Windows L&F, it places a two pixel white line to the left, and a one pixel white line on the bottom of the Component (see attached image).
Is there a way to remove this? Adding (or removing) a border only places one around the outside of the lines. I've looked at writing my own UI for this particular component, but I'm not sure where to start exactly (let alone how to use the Windows L&F class). I can use UIManager to set the offsets to 0, but that cuts off the default border. My own theories revolve around some sort of depreciated bevel effect that doesn't render in Windows 7. Any other ideas?
回答1:
This is Look and Feel dependable. Try modifying UIManager
value ofTabbedPane.contentBorderInsets
.
For example:
UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(1,1,1,1));
See UIManager Defaults (by @camickr) for other properties and their defaults.
EDIT:
I managed to clear the top line with TabbedPane.tabAreaInsets
:
UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(0,0,0,0));
UIManager.getDefaults().put("TabbedPane.tabAreaInsets", new Insets(0,0,0,0));
来源:https://stackoverflow.com/questions/20462165/jtabbedpane-in-windows-lf-with-unremovable-border