JTabbedPane in Windows L&F with unremovable border

泄露秘密 提交于 2019-12-25 08:17:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!