且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置JTabbedPane选项卡的高度,宽度,背景前景色(选中和未选中的选项卡)

更新时间:2023-01-05 20:31:34

您可以将新值设置为UIDefaults:

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

这是按键列表

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

对于Nimbus LookAndFeel,还有其他一些 Nimbus默认值,例如:

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