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

前端 未结 2 1449
暗喜
暗喜 2021-01-25 09:07

I\'m adding icons to tabs but i want the ImageIcon fits all the tabComponent.

\"enter

2条回答
  •  故里飘歌
    2021-01-25 09:21

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

    enter image description here

    UPDATE

    I found another solution setting this property

    UIManager.getLookAndFeelDefaults().put("TabbedPane:TabbedPaneTab.contentMargins",  new Insets(0, 0, 0, 0));
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题