How to set JTabbedPane Tab height width background foreground color (Both selected and Unselected Tab)

后端 未结 3 1024
一生所求
一生所求 2021-01-20 17:01

How to set the JTabbedPane Tab background and Foreground, Height and Width (Both selected and Unselected Tab)

3条回答
  •  青春惊慌失措
    2021-01-20 17:24

    You can set new values to the UIDefaults:

            UIDefaults def = UIManager.getLookAndFeelDefaults();
            def.put( "TabbedPane.foreground", Color.RED );
            def.put( "TabbedPane.textIconGap", new Integer(16) );
            def.put( "TabbedPane.background", Color.BLUE );
            def.put( "TabbedPane.tabInsets", new Insets(10,10,10,10) );
            def.put( "TabbedPane.selectedTabPadInsets", new Insets(10,20,10,20) );
    

    here are a list of Keys

    TabbedPane.textIconGap
    TabbedPane.contentOpaque
    TabbedPane.focus
    TabbedPane.foreground
    TabbedPane.tabRunOverlay
    TabbedPane.shadow
    TabbedPane.darkShadow
    TabbedPane.background
    TabbedPane.ancestorInputMap
    TabbedPane.focusInputMap
    TabbedPane.tabInsets
    TabbedPane.light
    TabbedPane.contentBorderInsets
    TabbedPane.tabsOverlapBorder
    TabbedPane.tabsOpaque
    TabbedPane.tabAreaInsets
    TabbedPane.highlight
    TabbedPane.font
    TabbedPane.selectedTabPadInsets
    

    For Nimbus LookAndFeel there are some other Nimbus Defaults like:

          TabbedPane:TabbedPaneTabArea.contentMargins
          TabbedPane:TabbedPaneTabArea[Enabled].backgroundPainter
          TabbedPane:TabbedPaneTab[Selected].backgroundPainter
          TabbedPane:TabbedPaneTabArea[Enabled].backgroundPainter
          TabbedPane:TabbedPaneTab.contentMargins
          TabbedPane.tabOverlap
    

提交回复
热议问题