home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / plaf / metal / MetalLookAndFeel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  21.3 KB  |  261 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.UIDefaults;
  4. import com.sun.java.swing.border.CompoundBorder;
  5. import com.sun.java.swing.border.LineBorder;
  6. import com.sun.java.swing.border.MatteBorder;
  7. import com.sun.java.swing.plaf.BorderUIResource;
  8. import com.sun.java.swing.plaf.ColorUIResource;
  9. import com.sun.java.swing.plaf.FontUIResource;
  10. import com.sun.java.swing.plaf.basic.BasicLookAndFeel;
  11. import com.sun.java.swing.plaf.basic.BasicMarginBorder;
  12.  
  13. public class MetalLookAndFeel extends BasicLookAndFeel {
  14.    private static MetalTheme currentTheme;
  15.  
  16.    public String getName() {
  17.       return "Metal Look and Feel";
  18.    }
  19.  
  20.    public String getID() {
  21.       return "Metal";
  22.    }
  23.  
  24.    public String getDescription() {
  25.       return "The Metal Look and Feel";
  26.    }
  27.  
  28.    public boolean isNativeLookAndFeel() {
  29.       return false;
  30.    }
  31.  
  32.    public boolean isSupportedLookAndFeel() {
  33.       return true;
  34.    }
  35.  
  36.    protected void initClassDefaults(UIDefaults var1) {
  37.       String var2 = "com.sun.java.swing.plaf.basic.";
  38.       String var3 = "com.sun.java.swing.plaf.metal.";
  39.       Object[] var4 = new Object[]{"ButtonUI", var3 + "MetalButtonUI", "CheckBoxUI", var3 + "MetalCheckBoxUI", "ColorChooserUI", var2 + "BasicColorChooserUI", "MenuBarUI", var2 + "BasicMenuBarUI", "MenuUI", var2 + "BasicMenuUI", "MenuItemUI", var2 + "BasicMenuItemUI", "CheckBoxMenuItemUI", var2 + "BasicCheckBoxMenuItemUI", "RadioButtonMenuItemUI", var2 + "BasicRadioButtonMenuItemUI", "RadioButtonUI", var3 + "MetalRadioButtonUI", "ToggleButtonUI", var3 + "MetalToggleButtonUI", "PopupMenuUI", var2 + "BasicPopupMenuUI", "ProgressBarUI", var3 + "MetalProgressBarUI", "ScrollBarUI", var3 + "MetalScrollBarUI", "ScrollPaneUI", var3 + "MetalScrollPaneUI", "SplitPaneUI", var2 + "BasicSplitPaneUI", "SliderUI", var3 + "MetalSliderUI", "SpinnerUI", var2 + "BasicSpinnerUI", "SeparatorUI", var3 + "MetalSeparatorUI", "TabbedPaneUI", var3 + "MetalTabbedPaneUI", "TextAreaUI", var2 + "BasicTextAreaUI", "TextFieldUI", var2 + "BasicTextFieldUI", "PasswordFieldUI", var2 + "BasicPasswordFieldUI", "TextPaneUI", var2 + "BasicTextPaneUI", "EditorPaneUI", var2 + "BasicEditorPaneUI", "TreeUI", var3 + "MetalTreeUI", "LabelUI", var3 + "MetalLabelUI", "ListUI", var2 + "BasicListUI", "ToolBarUI", var3 + "MetalToolBarUI", "ToolTipUI", var3 + "MetalToolTipUI", "ComboBoxUI", var3 + "MetalComboBoxUI", "TableUI", var2 + "BasicTableUI", "TableHeaderUI", var2 + "BasicTableHeaderUI", "InternalFrameUI", var3 + "MetalInternalFrameUI", "StandardDialogUI", var2 + "BasicStandardDialogUI", "DesktopPaneUI", var2 + "BasicDesktopPaneUI", "DesktopIconUI", var3 + "MetalDesktopIconUI", "DirectoryPaneUI", var2 + "BasicDirectoryPaneUI", "FileChooserUI", var2 + "BasicFileChooserUI", "OptionPaneUI", var2 + "BasicOptionPaneUI"};
  40.       var1.putDefaults(var4);
  41.    }
  42.  
  43.    protected void initSystemColorDefaults(UIDefaults var1) {
  44.       Object[] var2 = new Object[]{"desktop", getDesktopColor(), "activeCaption", getWindowTitleBackground(), "activeCaptionText", getWindowTitleForeground(), "activeCaptionBorder", getPrimaryControlShadow(), "inactiveCaption", getWindowTitleInactiveBackground(), "inactiveCaptionText", getWindowTitleInactiveForeground(), "inactiveCaptionBorder", getControlShadow(), "window", getWindowBackground(), "windowBorder", getControl(), "windowText", getUserTextColor(), "menu", getMenuBackground(), "menuText", getMenuForeground(), "text", getWindowBackground(), "textText", getUserTextColor(), "textHighlight", getTextHighlightColor(), "textHighlightText", getHighlightedTextColor(), "textInactiveText", getInactiveSystemTextColor(), "control", getControl(), "controlText", getControlTextColor(), "controlHighlight", getControlHighlight(), "controlLtHighlight", getControlHighlight(), "controlShadow", getControlShadow(), "controlDkShadow", getControlDarkShadow(), "scrollbar", getControl(), "info", getPrimaryControl(), "infoText", getPrimaryControlInfo()};
  45.  
  46.       for(int var3 = 0; var3 < var2.length; var3 += 2) {
  47.          var1.put((String)var2[var3], var2[var3 + 1]);
  48.       }
  49.  
  50.    }
  51.  
  52.    protected void initComponentDefaults(UIDefaults var1) {
  53.       super.initComponentDefaults(var1);
  54.       BorderUIResource var2 = new BorderUIResource(new CompoundBorder(new Flush3DBorder(), BasicMarginBorder.getMarginBorder()));
  55.       BorderUIResource var3 = new BorderUIResource(new MetalScrollPaneUI.ScrollPaneBorder());
  56.       BorderUIResource var4 = new BorderUIResource(new CompoundBorder(new MetalButtonBorder(), BasicMarginBorder.getMarginBorder()));
  57.       BorderUIResource var5 = new BorderUIResource(new CompoundBorder(new MetalToggleButtonUI.MetalToggleButtonBorder(), BasicMarginBorder.getMarginBorder()));
  58.       1 var6 = new 1();
  59.       BorderUIResource var7 = new BorderUIResource(new LineBorder(var1.getColor("controlShadow")));
  60.       BorderUIResource var8 = new BorderUIResource(new CompoundBorder(new LineBorder(getControlDarkShadow(), 1), new MatteBorder(2, 2, 1, 2, getControl())));
  61.       BorderUIResource var9 = new BorderUIResource(new MetalInternalFrameBorder());
  62.       BorderUIResource var10 = new BorderUIResource(new MetalMenuBarBorder());
  63.       BorderUIResource var11 = new BorderUIResource(new MetalPopupMenuBorder());
  64.       BorderUIResource var12 = new BorderUIResource(new MetalMenuItemBorder());
  65.       BorderUIResource var13 = new BorderUIResource(new MetalToolBarBorder());
  66.       BorderUIResource var14 = new BorderUIResource(new LineBorder(getFocusColor()));
  67.       Object[] var15 = new Object[]{"TextField.border", var2, "PasswordField.border", var2, "TextArea.border", var2, "TextPane.border", var2, "EditorPane.border", var2, "CheckBox.icon", new MetalCheckBoxIcon(), "CheckBox.font", getControlTextFont(), "CheckBox.focus", getFocusColor(), "Button.background", getControl(), "Button.foreground", getControlTextColor(), "Button.pressed", getControlShadow(), "Button.disabledText", getInactiveControlTextColor(), "Button.disabled", getControl(), "Button.border", var4, "Button.font", getControlTextFont(), "Button.focus", getFocusColor(), "DirectoryPane.directoryIcon", MetalIconFactory.getTreeFolderIcon(), "DirectoryPane.fileIcon", MetalIconFactory.getTreeLeafIcon(), "DirectoryPane.computerIcon", MetalIconFactory.getTreeComputerIcon(), "DirectoryPane.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(), "DirectoryPane.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(), "FileChooser.detailsView", MetalIconFactory.getFileChooserDetailViewIcon(), "FileChooser.homeFolder", MetalIconFactory.getFileChooserHomeFolderIcon(), "FileChooser.listView", MetalIconFactory.getFileChooserListViewIcon(), "FileChooser.newFolder", MetalIconFactory.getFileChooserNewFolderIcon(), "FileChooser.upFolder", MetalIconFactory.getFileChooserUpFolderIcon(), "InternalFrameTitlePane.closeIcon", MetalIconFactory.getInternalFrameCloseIcon(), "InternalFrameTitlePane.maximizeIcon", MetalIconFactory.getInternalFrameMaximizeIcon(), "InternalFrameTitlePane.iconizeIcon", MetalIconFactory.getInternalFrameMinimizeIcon(), "InternalFrameTitlePane.altMaximizeIcon", MetalIconFactory.getInternalFrameAltMaximizeIcon(), "InternalFrameTitlePane.font", getControlTextFont(), "RadioButton.icon", MetalIconFactory.getRadioButtonIcon(), "RadioButton.font", getControlTextFont(), "RadioButton.focus", getFocusColor(), "ToolTip.font", getSystemTextFont(), "ToolTip.border", null, "ToolTip.background", var1.get("info"), "ToolTip.foreground", var1.get("infoText"), "ToggleButton.background", getControl(), "ToggleButton.foreground", getControlTextColor(), "ToggleButton.pressed", getControlShadow(), "ToggleButton.selected", getControlShadow(), "ToggleButton.disabledText", getInactiveControlTextColor(), "ToggleButton.disabledSelectedText", getControlDarkShadow(), "ToggleButton.disabledBackground", getControl(), "ToggleButton.disabledSelectedBackground", getControlShadow(), "ToggleButton.focus", getFocusColor(), "ToggleButton.border", var5, "ToggleButton.font", getControlTextFont(), "Slider.border", null, "Slider.foreground", getPrimaryControlShadow(), "Slider.background", getControl(), "Slider.focus", getFocusColor(), "Slider.trackWidth", new Integer(9), "Slider.majorTickLength", new Integer(6), "Slider.horizontalThumbIcon", MetalIconFactory.getHorizontalSliderThumbIcon(), "Slider.verticalThumbIcon", MetalIconFactory.getVerticalSliderThumbIcon(), "ProgressBar.foreground", getPrimaryControlShadow(), "ProgressBar.background", getControl(), "ProgressBar.foregroundHighlight", getPrimaryControlShadow(), "ProgressBar.backgroundHighlight", getControl(), "ProgressBar.border", getControl(), "ComboBox.background", var1.get("control"), "ComboBox.foreground", var1.get("controlText"), "ComboBox.selectedBackground", getPrimaryControlShadow(), "ComboBox.selectedForeground", getControlTextColor(), "ComboBox.listBackground", getControl(), "ComboBox.listForeground", getControlTextColor(), "ComboBox.font", getControlTextFont(), "ComboBox.editor", var6, "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(), "InternalFrame.border", var9, "DesktopIcon.border", var8, "DesktopIcon.font", getControlTextFont(), "DesktopIcon.foreground", getControlTextColor(), "DesktopIcon.background", getControl(), "TitledBorder.font", getControlTextFont(), "TitledBorder.titleColor", getSystemTextColor(), "TitledBorder.border", var7, "Label.font", getControlTextFont(), "Label.background", var1.get("control"), "Label.foreground", getSystemTextColor(), "Label.disabled", getInactiveSystemTextColor(), "List.focusCellHighlightBorder", var14, "ScrollBar.background", getControl(), "ScrollBar.highlight", getControlHighlight(), "ScrollBar.shadow", getControlDarkShadow(), "ScrollBar.thumb", getPrimaryControlShadow(), "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(), "ScrollBar.thumbHighlight", getPrimaryControl(), "ScrollBar.width", new Integer(17), "ScrollPane.border", var3, "TabbedPane.font", getControlTextFont(), "TabbedPane.tabBackground", getControl(), "TabbedPane.tabForeground", getControlTextColor(), "TabbedPane.tabHighlight", getControlHighlight(), "TabbedPane.tabDarkShadow", getControlDarkShadow(), "TabbedPane.focus", getPrimaryControlDarkShadow(), "TabbedPane.selected", getPrimaryControlShadow(), "TabbedPane.selectHighlight", getPrimaryControl(), "Table.focusCellHighlightBorder", var14, "Table.focusCellBackground", getFocusColor(), "Table.scrollPaneBorder", var3, "MenuBar.border", var10, "MenuBar.font", getMenuTextFont(), "MenuBar.foreground", getMenuForeground(), "MenuBar.background", getMenuBackground(), "Menu.border", var12, "Menu.font", getMenuTextFont(), "Menu.foreground", getMenuForeground(), "Menu.background", getMenuBackground(), "Menu.pressedForeground", getMenuSelectedForeground(), "Menu.pressedBackground", getMenuSelectedBackground(), "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(), "MenuItem.border", var12, "MenuItem.borderPainted", Boolean.TRUE, "MenuItem.font", getMenuTextFont(), "MenuItem.acceleratorFont", getSubTextFont(), "MenuItem.acceleratorForeground", getAcceleratorForeground(), "MenuItem.acceleratorPressedForeground", getAcceleratorSelectedForeground(), "MenuItem.foreground", getMenuForeground(), "MenuItem.background", getMenuBackground(), "MenuItem.pressedForeground", getMenuSelectedForeground(), "MenuItem.pressedBackground", getMenuSelectedBackground(), "MenuItem.disabledForeground", getMenuDisabledForeground(), "MenuItem.acceleratorFont", getSubTextFont(), "MenuItem.acceleratorForeground", getAcceleratorForeground(), "MenuItem.acceleratorPressedForeground", getAcceleratorSelectedForeground(), "MenuItem.checkIcon", MetalIconFactory.getMenuItemCheckIcon(), "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(), "Separator.background", getSeparatorBackground(), "Separator.foreground", getSeparatorForeground(), "PopupMenu.background", getMenuBackground(), "PopupMenu.border", var11, "CheckBoxMenuItem.icon", MetalIconFactory.getCheckBoxMenuItemIcon(), "RadioButtonMenuItem.icon", MetalIconFactory.getRadioButtonMenuItemIcon(), "Tree.background", getWindowBackground(), "Tree.textSelectionColor", var1.get("textHighlightText"), "Tree.textNonSelectionColor", var1.get("textText"), "Tree.borderSelectionColor", getWindowBackground(), "Tree.backgroundSelectionColor", var1.get("textHighlight"), "Tree.backgroundNonSelectionColor", getWindowBackground(), "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(), "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(), "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(), "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false), "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true), "Tree.line", getPrimaryControl(), "Tree.hash", getPrimaryControl(), "ToolBar.border", var13, "ToolBar.background", getMenuBackground(), "ToolBar.foreground", getMenuForeground(), "ToolBar.font", getMenuTextFont(), "ToolBar.dockingColor", getMenuBackground(), "ToolBar.floatingColor", getMenuBackground(), "ToolBar.dockingBorderColor", getPrimaryControlDarkShadow(), "ToolBar.floatingBorderColor", getPrimaryControl()};
  68.       var1.putDefaults(var15);
  69.    }
  70.  
  71.    protected void createDefaultTheme() {
  72.       if (currentTheme == null) {
  73.          currentTheme = new DefaultMetalTheme();
  74.       }
  75.  
  76.    }
  77.  
  78.    public UIDefaults getDefaults() {
  79.       this.createDefaultTheme();
  80.       UIDefaults var1 = super.getDefaults();
  81.       currentTheme.addCustomEntriesToTable(var1);
  82.       return var1;
  83.    }
  84.  
  85.    public static void setCurrentTheme(MetalTheme var0) {
  86.       if (var0 == null) {
  87.          throw new NullPointerException("Can't have null theme");
  88.       } else {
  89.          currentTheme = var0;
  90.       }
  91.    }
  92.  
  93.    public static FontUIResource getControlTextFont() {
  94.       return currentTheme.getControlTextFont();
  95.    }
  96.  
  97.    public static FontUIResource getSystemTextFont() {
  98.       return currentTheme.getSystemTextFont();
  99.    }
  100.  
  101.    public static FontUIResource getUserTextFont() {
  102.       return currentTheme.getUserTextFont();
  103.    }
  104.  
  105.    public static FontUIResource getMenuTextFont() {
  106.       return currentTheme.getMenuTextFont();
  107.    }
  108.  
  109.    public static FontUIResource getEmphasisTextFont() {
  110.       return currentTheme.getEmphasisTextFont();
  111.    }
  112.  
  113.    public static FontUIResource getSubTextFont() {
  114.       return currentTheme.getSubTextFont();
  115.    }
  116.  
  117.    public static ColorUIResource getDesktopColor() {
  118.       return currentTheme.getDesktopColor();
  119.    }
  120.  
  121.    public static ColorUIResource getFocusColor() {
  122.       return currentTheme.getFocusColor();
  123.    }
  124.  
  125.    public static ColorUIResource getWhite() {
  126.       return currentTheme.getWhite();
  127.    }
  128.  
  129.    public static ColorUIResource getBlack() {
  130.       return currentTheme.getBlack();
  131.    }
  132.  
  133.    public static ColorUIResource getControl() {
  134.       return currentTheme.getControl();
  135.    }
  136.  
  137.    public static ColorUIResource getControlShadow() {
  138.       return currentTheme.getControlShadow();
  139.    }
  140.  
  141.    public static ColorUIResource getControlDarkShadow() {
  142.       return currentTheme.getControlDarkShadow();
  143.    }
  144.  
  145.    public static ColorUIResource getControlInfo() {
  146.       return currentTheme.getControlInfo();
  147.    }
  148.  
  149.    public static ColorUIResource getControlHighlight() {
  150.       return currentTheme.getControlHighlight();
  151.    }
  152.  
  153.    public static ColorUIResource getControlDisabled() {
  154.       return currentTheme.getControlDisabled();
  155.    }
  156.  
  157.    public static ColorUIResource getPrimaryControl() {
  158.       return currentTheme.getPrimaryControl();
  159.    }
  160.  
  161.    public static ColorUIResource getPrimaryControlShadow() {
  162.       return currentTheme.getPrimaryControlShadow();
  163.    }
  164.  
  165.    public static ColorUIResource getPrimaryControlDarkShadow() {
  166.       return currentTheme.getPrimaryControlDarkShadow();
  167.    }
  168.  
  169.    public static ColorUIResource getPrimaryControlInfo() {
  170.       return currentTheme.getPrimaryControlInfo();
  171.    }
  172.  
  173.    public static ColorUIResource getPrimaryControlHighlight() {
  174.       return currentTheme.getPrimaryControlHighlight();
  175.    }
  176.  
  177.    public static ColorUIResource getSystemTextColor() {
  178.       return currentTheme.getSystemTextColor();
  179.    }
  180.  
  181.    public static ColorUIResource getControlTextColor() {
  182.       return currentTheme.getControlTextColor();
  183.    }
  184.  
  185.    public static ColorUIResource getInactiveControlTextColor() {
  186.       return currentTheme.getInactiveControlTextColor();
  187.    }
  188.  
  189.    public static ColorUIResource getInactiveSystemTextColor() {
  190.       return currentTheme.getInactiveSystemTextColor();
  191.    }
  192.  
  193.    public static ColorUIResource getUserTextColor() {
  194.       return currentTheme.getUserTextColor();
  195.    }
  196.  
  197.    public static ColorUIResource getTextHighlightColor() {
  198.       return currentTheme.getTextHighlightColor();
  199.    }
  200.  
  201.    public static ColorUIResource getHighlightedTextColor() {
  202.       return currentTheme.getHighlightedTextColor();
  203.    }
  204.  
  205.    public static ColorUIResource getWindowBackground() {
  206.       return currentTheme.getWindowBackground();
  207.    }
  208.  
  209.    public static ColorUIResource getWindowTitleBackground() {
  210.       return currentTheme.getWindowTitleBackground();
  211.    }
  212.  
  213.    public static ColorUIResource getWindowTitleForeground() {
  214.       return currentTheme.getWindowTitleForeground();
  215.    }
  216.  
  217.    public static ColorUIResource getWindowTitleInactiveBackground() {
  218.       return currentTheme.getWindowTitleInactiveBackground();
  219.    }
  220.  
  221.    public static ColorUIResource getWindowTitleInactiveForeground() {
  222.       return currentTheme.getWindowTitleInactiveForeground();
  223.    }
  224.  
  225.    public static ColorUIResource getMenuBackground() {
  226.       return currentTheme.getMenuBackground();
  227.    }
  228.  
  229.    public static ColorUIResource getMenuForeground() {
  230.       return currentTheme.getMenuForeground();
  231.    }
  232.  
  233.    public static ColorUIResource getMenuSelectedBackground() {
  234.       return currentTheme.getMenuSelectedBackground();
  235.    }
  236.  
  237.    public static ColorUIResource getMenuSelectedForeground() {
  238.       return currentTheme.getMenuSelectedForeground();
  239.    }
  240.  
  241.    public static ColorUIResource getMenuDisabledForeground() {
  242.       return currentTheme.getMenuDisabledForeground();
  243.    }
  244.  
  245.    public static ColorUIResource getSeparatorBackground() {
  246.       return currentTheme.getSeparatorBackground();
  247.    }
  248.  
  249.    public static ColorUIResource getSeparatorForeground() {
  250.       return currentTheme.getSeparatorForeground();
  251.    }
  252.  
  253.    public static ColorUIResource getAcceleratorForeground() {
  254.       return currentTheme.getAcceleratorForeground();
  255.    }
  256.  
  257.    public static ColorUIResource getAcceleratorSelectedForeground() {
  258.       return currentTheme.getAcceleratorSelectedForeground();
  259.    }
  260. }
  261.