Is there any way to fit an image in a tab component

十年热恋 提交于 2019-12-02 07:27:38

You can try playing with the UIManager. Add the following at the start of your program before you start creating component:

UIManager.put("TabbedPane.tabInsets", new Insets(0, 0, 0, 0));

Of course not all LAF's may support this option. See UIManager Defaults for more information.

I found a solution, i don't know if it's the proper one, thanks to @camickr

tabbedPane.setUI(new SynthTabbedPaneUI(){

Insets insets =new Insets(0, 0, 0, 0);

@Override
protected Insets getTabInsets(int tabPlacement,
                  int tabIndex){
                  return insets;
}

});

UPDATE

I found another solution setting this property

UIManager.getLookAndFeelDefaults().put("TabbedPane:TabbedPaneTab.contentMargins",  new Insets(0, 0, 0, 0));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!