8035313: Change SwingLazyValue usage to lambda

Reviewed-by: malenkov, serb
This commit is contained in:
Alexander Scherbatiy 2014-03-03 14:24:01 +04:00
parent 9267ce8b88
commit c8ad756ad8
9 changed files with 252 additions and 572 deletions

View File

@ -32,8 +32,9 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicBorders;
import javax.swing.plaf.basic.BasicLookAndFeel; import javax.swing.plaf.basic.BasicLookAndFeel;
import static javax.swing.UIDefaults.LazyValue;
import sun.swing.*; import sun.swing.*;
import apple.laf.*; import apple.laf.*;
@ -43,8 +44,6 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
// for lazy initalizers. Following the pattern from metal. // for lazy initalizers. Following the pattern from metal.
private static final String PKG_PREFIX = "com.apple.laf."; private static final String PKG_PREFIX = "com.apple.laf.";
private static final String kAquaImageFactoryName = PKG_PREFIX + "AquaImageFactory";
private static final String kAquaFontsName = PKG_PREFIX + "AquaFonts";
/** /**
* Return a short string that identifies this look and feel, e.g. * Return a short string that identifies this look and feel, e.g.
@ -320,17 +319,21 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
// our launch times of Swing apps. // our launch times of Swing apps.
// *** Text value objects // *** Text value objects
final Object marginBorder = new SwingLazyValue("javax.swing.plaf.basic.BasicBorders$MarginBorder"); final LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
final Object zero = new Integer(0); final int zero = 0;
final Object editorMargin = zeroInsets; // this is not correct - look at TextEdit to determine the right margin final Object editorMargin = zeroInsets; // this is not correct - look at TextEdit to determine the right margin
final Object textCaretBlinkRate = new Integer(500); final int textCaretBlinkRate = 500;
final Object textFieldBorder = new SwingLazyValue(PKG_PREFIX + "AquaTextFieldBorder", "getTextFieldBorder"); final LazyValue textFieldBorder = t ->
AquaTextFieldBorder.getTextFieldBorder();
final Object textAreaBorder = marginBorder; // text areas have no real border - radar 311073 final Object textAreaBorder = marginBorder; // text areas have no real border - radar 311073
final Object scollListBorder = new SwingLazyValue(PKG_PREFIX + "AquaScrollRegionBorder", "getScrollRegionBorder"); final LazyValue scollListBorder = t ->
final Object aquaTitledBorder = new SwingLazyValue(PKG_PREFIX + "AquaGroupBorder", "getBorderForTitledBorder"); AquaScrollRegionBorder.getScrollRegionBorder();
final Object aquaInsetBorder = new SwingLazyValue(PKG_PREFIX + "AquaGroupBorder", "getTitlelessBorder"); final LazyValue aquaTitledBorder = t ->
AquaGroupBorder.getBorderForTitledBorder();
final LazyValue aquaInsetBorder = t ->
AquaGroupBorder.getTitlelessBorder();
final Border listHeaderBorder = AquaTableHeaderBorder.getListHeaderBorder(); final Border listHeaderBorder = AquaTableHeaderBorder.getListHeaderBorder();
final Border zeroBorder = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); final Border zeroBorder = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0);
@ -352,7 +355,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
final Color textPasswordFieldCapsLockIconColor = mediumTranslucentBlack; final Color textPasswordFieldCapsLockIconColor = mediumTranslucentBlack;
final Object internalFrameBorder = new SwingLazyValue("javax.swing.plaf.basic.BasicBorders", "getInternalFrameBorder"); final LazyValue internalFrameBorder = t ->
BasicBorders.getInternalFrameBorder();
final Color desktopBackgroundColor = new ColorUIResource(new Color(65, 105, 170));//SystemColor.desktop final Color desktopBackgroundColor = new ColorUIResource(new Color(65, 105, 170));//SystemColor.desktop
final Color focusRingColor = AquaImageFactory.getFocusRingColorUIResource(); final Color focusRingColor = AquaImageFactory.getFocusRingColorUIResource();
@ -363,11 +367,12 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
final Color tabBackgroundColor = windowBackgroundColor; final Color tabBackgroundColor = windowBackgroundColor;
final Color controlBackgroundColor = windowBackgroundColor; final Color controlBackgroundColor = windowBackgroundColor;
final Object controlFont = new SwingLazyValue(kAquaFontsName, "getControlTextFont"); final LazyValue controlFont = t -> AquaFonts.getControlTextFont();
final Object controlSmallFont = new SwingLazyValue(kAquaFontsName, "getControlTextSmallFont"); final LazyValue controlSmallFont = t ->
final Object alertHeaderFont = new SwingLazyValue(kAquaFontsName, "getAlertHeaderFont"); AquaFonts.getControlTextSmallFont();
final Object menuFont = new SwingLazyValue(kAquaFontsName, "getMenuFont"); final LazyValue alertHeaderFont = t -> AquaFonts.getAlertHeaderFont();
final Object viewFont = new SwingLazyValue(kAquaFontsName, "getViewFont"); final LazyValue menuFont = t -> AquaFonts.getMenuFont();
final LazyValue viewFont = t -> AquaFonts.getViewFont();
final Color menuBackgroundColor = new ColorUIResource(Color.white); final Color menuBackgroundColor = new ColorUIResource(Color.white);
final Color menuForegroundColor = black; final Color menuForegroundColor = black;
@ -389,10 +394,14 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
}); });
// sja testing // sja testing
final Object confirmIcon = new SwingLazyValue(kAquaImageFactoryName, "getConfirmImageIcon"); // AquaImageFactory.getConfirmImageIcon(); final LazyValue confirmIcon = t ->
final Object cautionIcon = new SwingLazyValue(kAquaImageFactoryName, "getCautionImageIcon"); // AquaImageFactory.getCautionImageIcon(); AquaImageFactory.getConfirmImageIcon();
final Object stopIcon = new SwingLazyValue(kAquaImageFactoryName, "getStopImageIcon"); // AquaImageFactory.getStopImageIcon(); final LazyValue cautionIcon = t ->
final Object securityIcon = new SwingLazyValue(kAquaImageFactoryName, "getLockImageIcon"); // AquaImageFactory.getLockImageIcon(); AquaImageFactory.getCautionImageIcon();
final LazyValue stopIcon = t ->
AquaImageFactory.getStopImageIcon();
final LazyValue securityIcon = t ->
AquaImageFactory.getLockImageIcon();
final AquaKeyBindings aquaKeyBindings = AquaKeyBindings.instance(); final AquaKeyBindings aquaKeyBindings = AquaKeyBindings.instance();
@ -404,7 +413,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Button.foreground", black, "Button.foreground", black,
"Button.disabledText", disabled, "Button.disabledText", disabled,
"Button.select", selected, "Button.select", selected,
"Button.border", new SwingLazyValue(PKG_PREFIX + "AquaButtonBorder", "getDynamicButtonBorder"), "Button.border",(LazyValue) t -> AquaButtonBorder.getDynamicButtonBorder(),
"Button.font", controlFont, "Button.font", controlFont,
"Button.textIconGap", new Integer(4), "Button.textIconGap", new Integer(4),
"Button.textShiftOffset", zero, // radar 3308129 - aqua doesn't move images when pressed. "Button.textShiftOffset", zero, // radar 3308129 - aqua doesn't move images when pressed.
@ -416,7 +425,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"CheckBox.foreground", black, "CheckBox.foreground", black,
"CheckBox.disabledText", disabled, "CheckBox.disabledText", disabled,
"CheckBox.select", selected, "CheckBox.select", selected,
"CheckBox.icon", new SwingLazyValue(PKG_PREFIX + "AquaButtonCheckBoxUI", "getSizingCheckBoxIcon"), "CheckBox.icon",(LazyValue) t -> AquaButtonCheckBoxUI.getSizingCheckBoxIcon(),
"CheckBox.font", controlFont, "CheckBox.font", controlFont,
"CheckBox.border", AquaButtonBorder.getBevelButtonBorder(), "CheckBox.border", AquaButtonBorder.getBevelButtonBorder(),
"CheckBox.margin", new InsetsUIResource(1, 1, 0, 1), "CheckBox.margin", new InsetsUIResource(1, 1, 0, 1),
@ -441,8 +450,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"CheckBoxMenuItem.border", menuBorder, // for inset calculation "CheckBoxMenuItem.border", menuBorder, // for inset calculation
"CheckBoxMenuItem.margin", menuItemMargin, "CheckBoxMenuItem.margin", menuItemMargin,
"CheckBoxMenuItem.borderPainted", Boolean.TRUE, "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
"CheckBoxMenuItem.checkIcon", new SwingLazyValue(kAquaImageFactoryName, "getMenuItemCheckIcon"), "CheckBoxMenuItem.checkIcon",(LazyValue) t -> AquaImageFactory.getMenuItemCheckIcon(),
"CheckBoxMenuItem.dashIcon", new SwingLazyValue(kAquaImageFactoryName, "getMenuItemDashIcon"), "CheckBoxMenuItem.dashIcon",(LazyValue) t -> AquaImageFactory.getMenuItemDashIcon(),
//"CheckBoxMenuItem.arrowIcon", null, //"CheckBoxMenuItem.arrowIcon", null,
"ColorChooser.background", panelBackgroundColor, "ColorChooser.background", panelBackgroundColor,
@ -538,10 +547,10 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
/* Default frame icons are undefined for Basic. */ /* Default frame icons are undefined for Basic. */
"InternalFrame.closeIcon", new SwingLazyValue(PKG_PREFIX + "AquaInternalFrameUI", "exportCloseIcon"), "InternalFrame.closeIcon",(LazyValue) t -> AquaInternalFrameUI.exportCloseIcon(),
"InternalFrame.maximizeIcon", new SwingLazyValue(PKG_PREFIX + "AquaInternalFrameUI", "exportZoomIcon"), "InternalFrame.maximizeIcon",(LazyValue) t -> AquaInternalFrameUI.exportZoomIcon(),
"InternalFrame.iconifyIcon", new SwingLazyValue(PKG_PREFIX + "AquaInternalFrameUI", "exportMinimizeIcon"), "InternalFrame.iconifyIcon",(LazyValue) t -> AquaInternalFrameUI.exportMinimizeIcon(),
"InternalFrame.minimizeIcon", new SwingLazyValue(PKG_PREFIX + "AquaInternalFrameUI", "exportMinimizeIcon"), "InternalFrame.minimizeIcon",(LazyValue) t -> AquaInternalFrameUI.exportMinimizeIcon(),
// this could be either grow or icon // this could be either grow or icon
// we decided to make it icon so that anyone who uses // we decided to make it icon so that anyone who uses
// these for ui will have different icons for max and min // these for ui will have different icons for max and min
@ -595,11 +604,11 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"List.border", null, "List.border", null,
"List.cellRenderer", listCellRendererActiveValue, "List.cellRenderer", listCellRendererActiveValue,
"List.sourceListBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaListUI", "getSourceListBackgroundPainter"), "List.sourceListBackgroundPainter",(LazyValue) t -> AquaListUI.getSourceListBackgroundPainter(),
"List.sourceListSelectionBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaListUI", "getSourceListSelectionBackgroundPainter"), "List.sourceListSelectionBackgroundPainter",(LazyValue) t -> AquaListUI.getSourceListSelectionBackgroundPainter(),
"List.sourceListFocusedSelectionBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaListUI", "getSourceListFocusedSelectionBackgroundPainter"), "List.sourceListFocusedSelectionBackgroundPainter",(LazyValue) t -> AquaListUI.getSourceListFocusedSelectionBackgroundPainter(),
"List.evenRowBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaListUI", "getListEvenBackgroundPainter"), "List.evenRowBackgroundPainter",(LazyValue) t -> AquaListUI.getListEvenBackgroundPainter(),
"List.oddRowBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaListUI", "getListOddBackgroundPainter"), "List.oddRowBackgroundPainter",(LazyValue) t -> AquaListUI.getListOddBackgroundPainter(),
// <rdar://Problem/3743210> The modifier for the Mac is meta, not control. // <rdar://Problem/3743210> The modifier for the Mac is meta, not control.
"List.focusInputMap", aquaKeyBindings.getListInputMap(), "List.focusInputMap", aquaKeyBindings.getListInputMap(),
@ -623,7 +632,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Menu.borderPainted", Boolean.FALSE, "Menu.borderPainted", Boolean.FALSE,
"Menu.margin", menuItemMargin, "Menu.margin", menuItemMargin,
//"Menu.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent //"Menu.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent
"Menu.arrowIcon", new SwingLazyValue(kAquaImageFactoryName, "getMenuArrowIcon"), "Menu.arrowIcon",(LazyValue) t -> AquaImageFactory.getMenuArrowIcon(),
"Menu.consumesTabs", Boolean.TRUE, "Menu.consumesTabs", Boolean.TRUE,
"Menu.menuPopupOffsetY", new Integer(1), "Menu.menuPopupOffsetY", new Integer(1),
"Menu.submenuPopupOffsetY", new Integer(-4), "Menu.submenuPopupOffsetY", new Integer(-4),
@ -637,8 +646,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"MenuBar.selectionForeground", menuSelectedForegroundColor, "MenuBar.selectionForeground", menuSelectedForegroundColor,
"MenuBar.disabledBackground", menuDisabledBackgroundColor, //ThemeBrush.GetThemeBrushForMenu(false, false), // not a menu item, not selected "MenuBar.disabledBackground", menuDisabledBackgroundColor, //ThemeBrush.GetThemeBrushForMenu(false, false), // not a menu item, not selected
"MenuBar.disabledForeground", menuDisabledForegroundColor, "MenuBar.disabledForeground", menuDisabledForegroundColor,
"MenuBar.backgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaMenuPainter", "getMenuBarPainter"), "MenuBar.backgroundPainter",(LazyValue) t -> AquaMenuPainter.getMenuBarPainter(),
"MenuBar.selectedBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaMenuPainter", "getSelectedMenuBarItemPainter"), "MenuBar.selectedBackgroundPainter",(LazyValue) t -> AquaMenuPainter.getSelectedMenuBarItemPainter(),
"MenuItem.font", menuFont, "MenuItem.font", menuFont,
"MenuItem.acceleratorFont", menuFont, "MenuItem.acceleratorFont", menuFont,
@ -656,7 +665,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"MenuItem.borderPainted", Boolean.TRUE, "MenuItem.borderPainted", Boolean.TRUE,
//"MenuItem.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent //"MenuItem.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent
//"MenuItem.arrowIcon", null, //"MenuItem.arrowIcon", null,
"MenuItem.selectedBackgroundPainter", new SwingLazyValue(PKG_PREFIX + "AquaMenuPainter", "getSelectedMenuItemPainter"), "MenuItem.selectedBackgroundPainter",(LazyValue) t -> AquaMenuPainter.getSelectedMenuItemPainter(),
// *** OptionPane // *** OptionPane
// You can additionaly define OptionPane.messageFont which will // You can additionaly define OptionPane.messageFont which will
@ -732,7 +741,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"RadioButton.foreground", black, "RadioButton.foreground", black,
"RadioButton.disabledText", disabled, "RadioButton.disabledText", disabled,
"RadioButton.select", selected, "RadioButton.select", selected,
"RadioButton.icon", new SwingLazyValue(PKG_PREFIX + "AquaButtonRadioUI", "getSizingRadioButtonIcon"), "RadioButton.icon",(LazyValue) t -> AquaButtonRadioUI.getSizingRadioButtonIcon(),
"RadioButton.font", controlFont, "RadioButton.font", controlFont,
"RadioButton.border", AquaButtonBorder.getBevelButtonBorder(), "RadioButton.border", AquaButtonBorder.getBevelButtonBorder(),
"RadioButton.margin", new InsetsUIResource(1, 1, 0, 1), "RadioButton.margin", new InsetsUIResource(1, 1, 0, 1),
@ -752,8 +761,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"RadioButtonMenuItem.border", menuBorder, // for inset calculation "RadioButtonMenuItem.border", menuBorder, // for inset calculation
"RadioButtonMenuItem.margin", menuItemMargin, "RadioButtonMenuItem.margin", menuItemMargin,
"RadioButtonMenuItem.borderPainted", Boolean.TRUE, "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
"RadioButtonMenuItem.checkIcon", new SwingLazyValue(kAquaImageFactoryName, "getMenuItemCheckIcon"), "RadioButtonMenuItem.checkIcon",(LazyValue) t -> AquaImageFactory.getMenuItemCheckIcon(),
"RadioButtonMenuItem.dashIcon", new SwingLazyValue(kAquaImageFactoryName, "getMenuItemDashIcon"), "RadioButtonMenuItem.dashIcon",(LazyValue) t -> AquaImageFactory.getMenuItemDashIcon(),
//"RadioButtonMenuItem.arrowIcon", null, //"RadioButtonMenuItem.arrowIcon", null,
"Separator.background", null, "Separator.background", null,
@ -808,7 +817,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"SplitPane.border", scollListBorder, "SplitPane.border", scollListBorder,
"SplitPane.dividerSize", new Integer(9), //$ "SplitPane.dividerSize", new Integer(9), //$
"SplitPaneDivider.border", null, // AquaSplitPaneDividerUI draws it "SplitPaneDivider.border", null, // AquaSplitPaneDividerUI draws it
"SplitPaneDivider.horizontalGradientVariant", new SwingLazyValue(PKG_PREFIX + "AquaSplitPaneDividerUI", "getHorizontalSplitDividerGradientVariant"), "SplitPaneDivider.horizontalGradientVariant",(LazyValue) t -> AquaSplitPaneDividerUI.getHorizontalSplitDividerGradientVariant(),
// *** TabbedPane // *** TabbedPane
"TabbedPane.font", controlFont, "TabbedPane.font", controlFont,
@ -918,7 +927,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
// "ToggleButton.disabledBackground", getControl(), // "ToggleButton.disabledBackground", getControl(),
// "ToggleButton.disabledSelectedBackground", getControlShadow(), // "ToggleButton.disabledSelectedBackground", getControlShadow(),
//"ToggleButton.focus", getFocusColor(), //"ToggleButton.focus", getFocusColor(),
"ToggleButton.border", new SwingLazyValue(PKG_PREFIX + "AquaButtonBorder", "getDynamicButtonBorder"), // sja make this lazy! "ToggleButton.border",(LazyValue) t -> AquaButtonBorder.getDynamicButtonBorder(), // sja make this lazy!
"ToggleButton.font", controlFont, "ToggleButton.font", controlFont,
"ToggleButton.focusInputMap", controlFocusInputMap, "ToggleButton.focusInputMap", controlFocusInputMap,
"ToggleButton.margin", new InsetsUIResource(2, 2, 2, 2), "ToggleButton.margin", new InsetsUIResource(2, 2, 2, 2),
@ -931,7 +940,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"ToolBar.dockingForeground", selectionBackground, "ToolBar.dockingForeground", selectionBackground,
"ToolBar.floatingBackground", panelBackgroundColor, "ToolBar.floatingBackground", panelBackgroundColor,
"ToolBar.floatingForeground", new ColorUIResource(Color.darkGray), "ToolBar.floatingForeground", new ColorUIResource(Color.darkGray),
"ToolBar.border", new SwingLazyValue(PKG_PREFIX + "AquaToolBarUI", "getToolBarBorder"), "ToolBar.border",(LazyValue) t -> AquaToolBarUI.getToolBarBorder(),
"ToolBar.borderHandleColor", toolbarDragHandleColor, "ToolBar.borderHandleColor", toolbarDragHandleColor,
//"ToolBar.separatorSize", new DimensionUIResource( 10, 10 ), //"ToolBar.separatorSize", new DimensionUIResource( 10, 10 ),
"ToolBar.separatorSize", null, "ToolBar.separatorSize", null,
@ -967,12 +976,12 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Tree.rightChildIndent", new Integer(13),//$ "Tree.rightChildIndent", new Integer(13),//$
"Tree.rowHeight", new Integer(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching "Tree.rowHeight", new Integer(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching
"Tree.scrollsOnExpand", Boolean.FALSE, "Tree.scrollsOnExpand", Boolean.FALSE,
"Tree.openIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeOpenFolderIcon"), // Open folder icon "Tree.openIcon",(LazyValue) t -> AquaImageFactory.getTreeOpenFolderIcon(), // Open folder icon
"Tree.closedIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeFolderIcon"), // Closed folder icon "Tree.closedIcon",(LazyValue) t -> AquaImageFactory.getTreeFolderIcon(), // Closed folder icon
"Tree.leafIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeDocumentIcon"), // Document icon "Tree.leafIcon",(LazyValue) t -> AquaImageFactory.getTreeDocumentIcon(), // Document icon
"Tree.expandedIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeExpandedIcon"), "Tree.expandedIcon",(LazyValue) t -> AquaImageFactory.getTreeExpandedIcon(),
"Tree.collapsedIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeCollapsedIcon"), "Tree.collapsedIcon",(LazyValue) t -> AquaImageFactory.getTreeCollapsedIcon(),
"Tree.rightToLeftCollapsedIcon", new SwingLazyValue(kAquaImageFactoryName, "getTreeRightToLeftCollapsedIcon"), "Tree.rightToLeftCollapsedIcon",(LazyValue) t -> AquaImageFactory.getTreeRightToLeftCollapsedIcon(),
"Tree.changeSelectionWithFocus", Boolean.TRUE, "Tree.changeSelectionWithFocus", Boolean.TRUE,
"Tree.drawsFocusBorderAroundIcon", Boolean.FALSE, "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
@ -1088,4 +1097,4 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
}; };
table.putDefaults(uiDefaults); table.putDefaults(uiDefaults);
} }
} }

View File

@ -336,10 +336,9 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
// populate the table with the values from basic. // populate the table with the values from basic.
super.initComponentDefaults(table); super.initComponentDefaults(table);
Integer zero = Integer.valueOf(0); UIDefaults.LazyValue zeroBorder =
Object zeroBorder = new sun.swing.SwingLazyValue( t -> new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0);
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
new Object[] {zero, zero, zero, zero});
Object focusBorder = new GTKStyle.GTKLazyValue( Object focusBorder = new GTKStyle.GTKLazyValue(
"com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder", "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder",
"getUnselectedCellBorder"); "getUnselectedCellBorder");

View File

@ -52,6 +52,7 @@ import javax.swing.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.text.DefaultEditorKit; import javax.swing.text.DefaultEditorKit;
import static javax.swing.UIDefaults.LazyValue;
import java.awt.Font; import java.awt.Font;
import java.awt.Color; import java.awt.Color;
@ -67,9 +68,10 @@ import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle; import sun.swing.DefaultLayoutStyle;
import sun.swing.ImageIconUIResource; import sun.swing.ImageIconUIResource;
import sun.swing.SwingLazyValue; import sun.swing.icon.SortArrowIcon;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import sun.swing.StringUIClientPropertyKey; import sun.swing.StringUIClientPropertyKey;
import sun.swing.plaf.windows.ClassicSortArrowIcon;
import static com.sun.java.swing.plaf.windows.TMSchema.*; import static com.sun.java.swing.plaf.windows.TMSchema.*;
import static com.sun.java.swing.plaf.windows.XPStyle.Skin; import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
@ -296,27 +298,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
initResourceBundle(table); initResourceBundle(table);
// *** Shared Fonts // *** Shared Fonts
Integer twelve = Integer.valueOf(12); LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
Integer fontPlain = Integer.valueOf(Font.PLAIN);
Integer fontBold = Integer.valueOf(Font.BOLD);
Object dialogPlain12 = new SwingLazyValue( LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
"javax.swing.plaf.FontUIResource", LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
null, LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
new Object[] {Font.DIALOG, fontPlain, twelve});
Object sansSerifPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.SANS_SERIF, fontPlain, twelve});
Object monospacedPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.MONOSPACED, fontPlain, twelve});
Object dialogBold12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.DIALOG, fontBold, twelve});
// *** Colors // *** Colors
// XXX - some of these doens't seem to be used // XXX - some of these doens't seem to be used
@ -757,9 +743,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR, "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR,
WindowBackgroundColor), WindowBackgroundColor),
"FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW, "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
new SwingLazyValue( (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource")),
"FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView", "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
"icons/ListView.gif"), "icons/ListView.gif"),
"FileChooser.listViewWindowsStyle", Boolean.TRUE, "FileChooser.listViewWindowsStyle", Boolean.TRUE,
@ -849,15 +833,12 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"InternalFrame.closeIcon", "InternalFrame.closeIcon",
WindowsIconFactory.createFrameCloseIcon(), WindowsIconFactory.createFrameCloseIcon(),
"InternalFrame.icon", "InternalFrame.icon",
new SwingLazyValue( (LazyValue) t -> new Object[]{
"com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane$ScalableIconUIResource",
// The constructor takes one arg: an array of UIDefaults.LazyValue // The constructor takes one arg: an array of UIDefaults.LazyValue
// representing the icons // representing the icons
new Object[][] { {
SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"), SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png") SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
} }), },
// Internal Frame Auditory Cue Mappings // Internal Frame Auditory Cue Mappings
"InternalFrame.closeSound", "win.sound.close", "InternalFrame.closeSound", "win.sound.close",
"InternalFrame.maximizeSound", "win.sound.maximize", "InternalFrame.maximizeSound", "win.sound.maximize",
@ -1715,9 +1696,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
String POPUP_MENU_BORDER = "PopupMenu.border"; String POPUP_MENU_BORDER = "PopupMenu.border";
Object popupMenuBorder = new XPBorderValue(Part.MENU, Object popupMenuBorder = new XPBorderValue(Part.MENU,
new SwingLazyValue( (LazyValue) t -> BasicBorders.getInternalFrameBorder(),
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder"),
BorderFactory.createEmptyBorder(2, 2, 2, 2)); BorderFactory.createEmptyBorder(2, 2, 2, 2));
table.put(POPUP_MENU_BORDER, popupMenuBorder); table.put(POPUP_MENU_BORDER, popupMenuBorder);
/* END handling menus for Vista */ /* END handling menus for Vista */
@ -1725,14 +1704,10 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
/* START table handling for Vista */ /* START table handling for Vista */
table.put("Table.ascendingSortIcon", new XPValue( table.put("Table.ascendingSortIcon", new XPValue(
new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN), new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
new SwingLazyValue( (LazyValue) t -> new ClassicSortArrowIcon(true)));
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.TRUE })));
table.put("Table.descendingSortIcon", new XPValue( table.put("Table.descendingSortIcon", new XPValue(
new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP), new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
new SwingLazyValue( (LazyValue) t -> new ClassicSortArrowIcon(false)));
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.FALSE })));
/* END table handling for Vista */ /* END table handling for Vista */
} }
@ -1757,15 +1732,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object buttonBorder = Object buttonBorder =
new XPBorderValue(Part.BP_PUSHBUTTON, new XPBorderValue(Part.BP_PUSHBUTTON,
new SwingLazyValue( (LazyValue) t -> BasicBorders.getButtonBorder());
"javax.swing.plaf.basic.BasicBorders",
"getButtonBorder"));
Object textFieldBorder = Object textFieldBorder =
new XPBorderValue(Part.EP_EDIT, new XPBorderValue(Part.EP_EDIT,
new SwingLazyValue( (LazyValue) t -> BasicBorders.getTextFieldBorder());
"javax.swing.plaf.basic.BasicBorders",
"getTextFieldBorder"));
Object textFieldMargin = Object textFieldMargin =
new XPValue(new InsetsUIResource(2, 2, 2, 2), new XPValue(new InsetsUIResource(2, 2, 2, 2),
@ -1782,44 +1753,27 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder); Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder);
// For focus rectangle for cells and trees. // For focus rectangle for cells and trees.
Object focusCellHighlightBorder = new SwingLazyValue( LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getFocusCellHighlightBorder");
Object etchedBorder = new SwingLazyValue( LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
"javax.swing.plaf.BorderUIResource",
"getEtchedBorderUIResource");
Object internalFrameBorder = new SwingLazyValue( LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getInternalFrameBorder");
Object loweredBevelBorder = new SwingLazyValue( LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource");
Object marginBorder = new SwingLazyValue( LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
"javax.swing.plaf.basic.BasicBorders$MarginBorder");
Object menuBarBorder = new SwingLazyValue( LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
"javax.swing.plaf.basic.BasicBorders",
"getMenuBarBorder");
Object popupMenuBorder = new XPBorderValue(Part.MENU, Object popupMenuBorder = new XPBorderValue(Part.MENU,
new SwingLazyValue( (LazyValue) t -> BasicBorders.getInternalFrameBorder());
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder"));
// *** ProgressBar // *** ProgressBar
Object progressBarBorder = new SwingLazyValue( LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getProgressBarBorder");
Object radioButtonBorder = new SwingLazyValue( LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
"javax.swing.plaf.basic.BasicBorders",
"getRadioButtonBorder");
Object scrollPaneBorder = Object scrollPaneBorder =
new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder); new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
@ -1827,45 +1781,27 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object tableScrollPaneBorder = Object tableScrollPaneBorder =
new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder); new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
Object tableHeaderBorder = new SwingLazyValue( LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getTableHeaderBorder");
// *** ToolBar // *** ToolBar
Object toolBarBorder = new SwingLazyValue( LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getToolBarBorder");
// *** ToolTips // *** ToolTips
Object toolTipBorder = new SwingLazyValue( LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
"javax.swing.plaf.BorderUIResource",
"getBlackLineBorderUIResource");
Object checkBoxIcon = new SwingLazyValue( LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getCheckBoxIcon");
Object radioButtonIcon = new SwingLazyValue( LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getRadioButtonIcon");
Object radioButtonMenuItemIcon = new SwingLazyValue( LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getRadioButtonMenuItemIcon");
Object menuItemCheckIcon = new SwingLazyValue( LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuItemCheckIcon");
Object menuItemArrowIcon = new SwingLazyValue( LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuItemArrowIcon");
Object menuArrowIcon = new SwingLazyValue( LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuArrowIcon");
Object[] lazyDefaults = { Object[] lazyDefaults = {
@ -1910,21 +1846,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"InternalFrame.layoutTitlePaneAtOrigin", "InternalFrame.layoutTitlePaneAtOrigin",
new XPValue(Boolean.TRUE, Boolean.FALSE), new XPValue(Boolean.TRUE, Boolean.FALSE),
"Table.ascendingSortIcon", new XPValue( "Table.ascendingSortIcon", new XPValue(
new SwingLazyValue( (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
"sun.swing.icon.SortArrowIcon", (LazyValue) t -> new ClassicSortArrowIcon(true)),
null, new Object[] { Boolean.TRUE,
"Table.sortIconColor" }),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.TRUE })),
"Table.descendingSortIcon", new XPValue( "Table.descendingSortIcon", new XPValue(
new SwingLazyValue( (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
"sun.swing.icon.SortArrowIcon", (LazyValue) t -> new ClassicSortArrowIcon(false)),
null, new Object[] { Boolean.FALSE,
"Table.sortIconColor" }),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.FALSE })),
}; };
return lazyDefaults; return lazyDefaults;
@ -2634,4 +2560,4 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
} }
} }
} }

View File

@ -58,7 +58,6 @@ import sun.swing.SwingUtilities2;
import sun.swing.SwingUtilities2.Section; import sun.swing.SwingUtilities2.Section;
import static sun.swing.SwingUtilities2.Section.*; import static sun.swing.SwingUtilities2.Section.*;
import sun.swing.PrintingStatus; import sun.swing.PrintingStatus;
import sun.swing.SwingLazyValue;
/** /**
* The <code>JTable</code> is used to display and edit regular two-dimensional tables * The <code>JTable</code> is used to display and edit regular two-dimensional tables

View File

@ -49,8 +49,8 @@ import javax.sound.sampled.*;
import sun.awt.AppContext; import sun.awt.AppContext;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.swing.SwingLazyValue;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import sun.swing.icon.SortArrowIcon;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
@ -74,6 +74,7 @@ import javax.swing.plaf.*;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import javax.swing.text.DefaultEditorKit; import javax.swing.text.DefaultEditorKit;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import static javax.swing.UIDefaults.LazyValue;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.awt.Window; import java.awt.Window;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
@ -459,30 +460,16 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Shared Longs // *** Shared Longs
Long oneThousand = new Long(1000); Long oneThousand = new Long(1000);
// *** Shared Fonts LazyValue dialogPlain12 = t ->
Integer twelve = new Integer(12); new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
Integer fontPlain = new Integer(Font.PLAIN); LazyValue serifPlain12 = t ->
Integer fontBold = new Integer(Font.BOLD); new FontUIResource(Font.SERIF, Font.PLAIN, 12);
Object dialogPlain12 = new SwingLazyValue( LazyValue sansSerifPlain12 = t ->
"javax.swing.plaf.FontUIResource", new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
null, LazyValue monospacedPlain12 = t ->
new Object[] {Font.DIALOG, fontPlain, twelve}); new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
Object serifPlain12 = new SwingLazyValue( LazyValue dialogBold12 = t ->
"javax.swing.plaf.FontUIResource", new FontUIResource(Font.DIALOG, Font.BOLD, 12);
null,
new Object[] {Font.SERIF, fontPlain, twelve});
Object sansSerifPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.SANS_SERIF, fontPlain, twelve});
Object monospacedPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.MONOSPACED, fontPlain, twelve});
Object dialogBold12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.DIALOG, fontBold, twelve});
// *** Shared Colors // *** Shared Colors
@ -515,55 +502,40 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3); InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3);
// *** Shared Borders // *** Shared Borders
Object marginBorder = new SwingLazyValue( LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
"javax.swing.plaf.basic.BasicBorders$MarginBorder"); LazyValue etchedBorder = t ->
Object etchedBorder = new SwingLazyValue( BorderUIResource.getEtchedBorderUIResource();
"javax.swing.plaf.BorderUIResource", LazyValue loweredBevelBorder = t ->
"getEtchedBorderUIResource"); BorderUIResource.getLoweredBevelBorderUIResource();
Object loweredBevelBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource");
Object popupMenuBorder = new SwingLazyValue( LazyValue popupMenuBorder = t -> BasicBorders.getInternalFrameBorder();
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder");
Object blackLineBorder = new SwingLazyValue( LazyValue blackLineBorder = t ->
"javax.swing.plaf.BorderUIResource", BorderUIResource.getBlackLineBorderUIResource();
"getBlackLineBorderUIResource"); LazyValue focusCellHighlightBorder = t ->
Object focusCellHighlightBorder = new SwingLazyValue( new BorderUIResource.LineBorderUIResource(yellow);
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
null,
new Object[] {yellow});
Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1); Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1);
Object tableHeaderBorder = new SwingLazyValue( LazyValue tableHeaderBorder = t ->
"javax.swing.plaf.BorderUIResource$BevelBorderUIResource", new BorderUIResource.BevelBorderUIResource(
null, BevelBorder.RAISED,
new Object[] { new Integer(BevelBorder.RAISED),
controlLtHighlight, controlLtHighlight,
control, control,
controlDkShadow, controlDkShadow,
controlShadow }); controlShadow);
// *** Button value objects // *** Button value objects
Object buttonBorder = LazyValue buttonBorder =
new SwingLazyValue( t -> BasicBorders.getButtonBorder();
"javax.swing.plaf.basic.BasicBorders",
"getButtonBorder");
Object buttonToggleBorder = LazyValue buttonToggleBorder =
new SwingLazyValue( t -> BasicBorders.getToggleButtonBorder();
"javax.swing.plaf.basic.BasicBorders",
"getToggleButtonBorder");
Object radioButtonBorder = LazyValue radioButtonBorder =
new SwingLazyValue( t -> BasicBorders.getRadioButtonBorder();
"javax.swing.plaf.basic.BasicBorders",
"getRadioButtonBorder");
// *** FileChooser / FileView value objects // *** FileChooser / FileView value objects
@ -601,9 +573,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** InternalFrame value objects // *** InternalFrame value objects
Object internalFrameBorder = new SwingLazyValue( LazyValue internalFrameBorder = t ->
"javax.swing.plaf.basic.BasicBorders", BasicBorders.getInternalFrameBorder();
"getInternalFrameBorder");
// *** List value objects // *** List value objects
@ -616,46 +587,30 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Menus value objects // *** Menus value objects
Object menuBarBorder = LazyValue menuBarBorder =
new SwingLazyValue( t -> BasicBorders.getMenuBarBorder();
"javax.swing.plaf.basic.BasicBorders",
"getMenuBarBorder");
Object menuItemCheckIcon = LazyValue menuItemCheckIcon =
new SwingLazyValue( t -> BasicIconFactory.getMenuItemCheckIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuItemCheckIcon");
Object menuItemArrowIcon = LazyValue menuItemArrowIcon =
new SwingLazyValue( t -> BasicIconFactory.getMenuItemArrowIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuItemArrowIcon");
Object menuArrowIcon = LazyValue menuArrowIcon =
new SwingLazyValue( t -> BasicIconFactory.getMenuArrowIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuArrowIcon");
Object checkBoxIcon = LazyValue checkBoxIcon =
new SwingLazyValue( t -> BasicIconFactory.getCheckBoxIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getCheckBoxIcon");
Object radioButtonIcon = LazyValue radioButtonIcon =
new SwingLazyValue( t -> BasicIconFactory.getRadioButtonIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getRadioButtonIcon");
Object checkBoxMenuItemIcon = LazyValue checkBoxMenuItemIcon =
new SwingLazyValue( t -> BasicIconFactory.getCheckBoxMenuItemIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getCheckBoxMenuItemIcon");
Object radioButtonMenuItemIcon = LazyValue radioButtonMenuItemIcon =
new SwingLazyValue( t -> BasicIconFactory.getRadioButtonMenuItemIcon();
"javax.swing.plaf.basic.BasicIconFactory",
"getRadioButtonMenuItemIcon");
Object menuItemAcceleratorDelimiter = "+"; Object menuItemAcceleratorDelimiter = "+";
@ -663,27 +618,22 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
Object optionPaneMinimumSize = new DimensionUIResource(262, 90); Object optionPaneMinimumSize = new DimensionUIResource(262, 90);
Integer zero = new Integer(0); int zero = 0;
Object zeroBorder = new SwingLazyValue( LazyValue zeroBorder = t ->
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", new BorderUIResource.EmptyBorderUIResource(zero, zero, zero, zero);
new Object[] {zero, zero, zero, zero});
Integer ten = new Integer(10); int ten = 10;
Object optionPaneBorder = new SwingLazyValue( LazyValue optionPaneBorder = t ->
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", new BorderUIResource.EmptyBorderUIResource(ten, ten, 12, ten);
new Object[] {ten, ten, twelve, ten});
Object optionPaneButtonAreaBorder = new SwingLazyValue( LazyValue optionPaneButtonAreaBorder = t ->
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", new BorderUIResource.EmptyBorderUIResource(6, zero, zero, zero);
new Object[] {new Integer(6), zero, zero, zero});
// *** ProgessBar value objects // *** ProgessBar value objects
Object progressBarBorder = LazyValue progressBarBorder =
new SwingLazyValue( t -> BasicBorders.getProgressBarBorder();
"javax.swing.plaf.basic.BasicBorders",
"getProgressBarBorder");
// ** ScrollBar value objects // ** ScrollBar value objects
@ -699,14 +649,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** SplitPane value objects // *** SplitPane value objects
Object splitPaneBorder = LazyValue splitPaneBorder =
new SwingLazyValue( t -> BasicBorders.getSplitPaneBorder();
"javax.swing.plaf.basic.BasicBorders", LazyValue splitPaneDividerBorder =
"getSplitPaneBorder"); t -> BasicBorders.getSplitPaneDividerBorder();
Object splitPaneDividerBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getSplitPaneDividerBorder");
// ** TabbedBane value objects // ** TabbedBane value objects
@ -721,10 +667,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Text value objects // *** Text value objects
Object textFieldBorder = LazyValue textFieldBorder =
new SwingLazyValue( t -> BasicBorders.getTextFieldBorder();
"javax.swing.plaf.basic.BasicBorders",
"getTextFieldBorder");
Object editorMargin = threeInsets; Object editorMargin = threeInsets;
@ -899,21 +843,13 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
/* Default frame icons are undefined for Basic. */ /* Default frame icons are undefined for Basic. */
"InternalFrame.maximizeIcon", "InternalFrame.maximizeIcon",
new SwingLazyValue( (LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
"InternalFrame.minimizeIcon", "InternalFrame.minimizeIcon",
new SwingLazyValue( (LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
"InternalFrame.iconifyIcon", "InternalFrame.iconifyIcon",
new SwingLazyValue( (LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
"InternalFrame.closeIcon", "InternalFrame.closeIcon",
new SwingLazyValue( (LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
// InternalFrame Auditory Cue Mappings // InternalFrame Auditory Cue Mappings
"InternalFrame.closeSound", null, "InternalFrame.closeSound", null,
"InternalFrame.maximizeSound", null, "InternalFrame.maximizeSound", null,
@ -1576,14 +1512,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
"ctrl shift PAGE_UP", "scrollRightExtendSelection", "ctrl shift PAGE_UP", "scrollRightExtendSelection",
"ctrl shift PAGE_DOWN", "scrollLeftExtendSelection", "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
}), }),
"Table.ascendingSortIcon", new SwingLazyValue( "Table.ascendingSortIcon", (LazyValue) t ->
"sun.swing.icon.SortArrowIcon", new SortArrowIcon(true, "Table.sortIconColor"),
null, new Object[] { Boolean.TRUE, "Table.descendingSortIcon", (LazyValue) t ->
"Table.sortIconColor" }), new SortArrowIcon(false, "Table.sortIconColor"),
"Table.descendingSortIcon", new SwingLazyValue(
"sun.swing.icon.SortArrowIcon",
null, new Object[] { Boolean.FALSE,
"Table.sortIconColor" }),
"Table.sortIconColor", controlShadow, "Table.sortIconColor", controlShadow,
"TableHeader.font", dialogPlain12, "TableHeader.font", dialogPlain12,
@ -2324,4 +2256,4 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
} }
} }
} }
} }

View File

@ -45,7 +45,7 @@ import java.security.PrivilegedAction;
import sun.awt.*; import sun.awt.*;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle; import sun.swing.DefaultLayoutStyle;
import sun.swing.SwingLazyValue; import static javax.swing.UIDefaults.LazyValue;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
/** /**
@ -457,9 +457,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
Integer zero = Integer.valueOf(0); Integer zero = Integer.valueOf(0);
Object textFieldBorder = LazyValue textFieldBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders", t -> MetalBorders.getTextFieldBorder();
"getTextFieldBorder");
Object dialogBorder = new MetalLazyValue( Object dialogBorder = new MetalLazyValue(
"javax.swing.plaf.metal.MetalBorders$DialogBorder"); "javax.swing.plaf.metal.MetalBorders$DialogBorder");
@ -614,61 +613,47 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
}); });
Object scrollPaneBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder"); LazyValue scrollPaneBorder = t -> new MetalBorders.ScrollPaneBorder();
Object buttonBorder = LazyValue buttonBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders", t -> MetalBorders.getButtonBorder();
"getButtonBorder");
Object toggleButtonBorder = LazyValue toggleButtonBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders", t -> MetalBorders.getToggleButtonBorder();
"getToggleButtonBorder");
Object titledBorderBorder = LazyValue titledBorderBorder =
new SwingLazyValue( t -> new BorderUIResource.LineBorderUIResource(controlShadow);
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {controlShadow});
Object desktopIconBorder = LazyValue desktopIconBorder =
new SwingLazyValue( t -> MetalBorders.getDesktopIconBorder();
"javax.swing.plaf.metal.MetalBorders",
"getDesktopIconBorder");
Object menuBarBorder = LazyValue menuBarBorder =
new SwingLazyValue( t -> new MetalBorders.MenuBarBorder();
"javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
Object popupMenuBorder = LazyValue popupMenuBorder =
new SwingLazyValue( t -> new MetalBorders.PopupMenuBorder();
"javax.swing.plaf.metal.MetalBorders$PopupMenuBorder"); LazyValue menuItemBorder =
Object menuItemBorder = t -> new MetalBorders.MenuItemBorder();
new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
Object menuItemAcceleratorDelimiter = "-"; Object menuItemAcceleratorDelimiter = "-";
Object toolBarBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ToolBarBorder"); LazyValue toolBarBorder = t -> new MetalBorders.ToolBarBorder();
Object progressBarBorder = new SwingLazyValue( LazyValue progressBarBorder = t ->
"javax.swing.plaf.BorderUIResource$LineBorderUIResource", new BorderUIResource.LineBorderUIResource(controlDarkShadow, new Integer(1));
new Object[] {controlDarkShadow, new Integer(1)});
Object toolTipBorder = new SwingLazyValue( LazyValue toolTipBorder = t ->
"javax.swing.plaf.BorderUIResource$LineBorderUIResource", new BorderUIResource.LineBorderUIResource(primaryControlDarkShadow);
new Object[] {primaryControlDarkShadow});
Object toolTipBorderInactive = new SwingLazyValue( LazyValue toolTipBorderInactive = t ->
"javax.swing.plaf.BorderUIResource$LineBorderUIResource", new BorderUIResource.LineBorderUIResource(controlDarkShadow);
new Object[] {controlDarkShadow});
Object focusCellHighlightBorder = new SwingLazyValue( LazyValue focusCellHighlightBorder = t ->
"javax.swing.plaf.BorderUIResource$LineBorderUIResource", new BorderUIResource.LineBorderUIResource(focusColor);
new Object[] {focusColor});
Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6); Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6);
Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9); Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
final Object[] internalFrameIconArgs = new Object[1]; int internalFrameIconSize = 16;
internalFrameIconArgs[0] = new Integer(16);
Object[] defaultCueList = new Object[] { Object[] defaultCueList = new Object[] {
"OptionPane.errorSound", "OptionPane.errorSound",
@ -794,7 +779,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Checkbox.select", controlShadow, "Checkbox.select", controlShadow,
"CheckBox.font", controlTextValue, "CheckBox.font", controlTextValue,
"CheckBox.focus", focusColor, "CheckBox.focus", focusColor,
"CheckBox.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxIcon"), "CheckBox.icon",(LazyValue) t -> MetalIconFactory.getCheckBoxIcon(),
"CheckBox.focusInputMap", "CheckBox.focusInputMap",
new UIDefaults.LazyInputMap(new Object[] { new UIDefaults.LazyInputMap(new Object[] {
"SPACE", "pressed", "SPACE", "pressed",
@ -806,7 +791,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"RadioButton.disabledText", inactiveControlTextColor, "RadioButton.disabledText", inactiveControlTextColor,
"RadioButton.select", controlShadow, "RadioButton.select", controlShadow,
"RadioButton.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonIcon"), "RadioButton.icon",(LazyValue) t -> MetalIconFactory.getRadioButtonIcon(),
"RadioButton.font", controlTextValue, "RadioButton.font", controlTextValue,
"RadioButton.focus", focusColor, "RadioButton.focus", focusColor,
"RadioButton.focusInputMap", "RadioButton.focusInputMap",
@ -831,18 +816,18 @@ public class MetalLookAndFeel extends BasicLookAndFeel
// File View // File View
"FileView.directoryIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"), "FileView.directoryIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"FileView.fileIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"), "FileView.fileIcon",(LazyValue) t -> MetalIconFactory.getTreeLeafIcon(),
"FileView.computerIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeComputerIcon"), "FileView.computerIcon",(LazyValue) t -> MetalIconFactory.getTreeComputerIcon(),
"FileView.hardDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeHardDriveIcon"), "FileView.hardDriveIcon",(LazyValue) t -> MetalIconFactory.getTreeHardDriveIcon(),
"FileView.floppyDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFloppyDriveIcon"), "FileView.floppyDriveIcon",(LazyValue) t -> MetalIconFactory.getTreeFloppyDriveIcon(),
// File Chooser // File Chooser
"FileChooser.detailsViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserDetailViewIcon"), "FileChooser.detailsViewIcon",(LazyValue) t -> MetalIconFactory.getFileChooserDetailViewIcon(),
"FileChooser.homeFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserHomeFolderIcon"), "FileChooser.homeFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserHomeFolderIcon(),
"FileChooser.listViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserListViewIcon"), "FileChooser.listViewIcon",(LazyValue) t -> MetalIconFactory.getFileChooserListViewIcon(),
"FileChooser.newFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserNewFolderIcon"), "FileChooser.newFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserNewFolderIcon(),
"FileChooser.upFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserUpFolderIcon"), "FileChooser.upFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserUpFolderIcon(),
"FileChooser.usesSingleFilePane", Boolean.TRUE, "FileChooser.usesSingleFilePane", Boolean.TRUE,
"FileChooser.ancestorInputMap", "FileChooser.ancestorInputMap",
@ -873,8 +858,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Slider.focusInsets", zeroInsets, "Slider.focusInsets", zeroInsets,
"Slider.trackWidth", new Integer( 7 ), "Slider.trackWidth", new Integer( 7 ),
"Slider.majorTickLength", new Integer( 6 ), "Slider.majorTickLength", new Integer( 6 ),
"Slider.horizontalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getHorizontalSliderThumbIcon"), "Slider.horizontalThumbIcon",(LazyValue) t -> MetalIconFactory.getHorizontalSliderThumbIcon(),
"Slider.verticalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getVerticalSliderThumbIcon"), "Slider.verticalThumbIcon",(LazyValue) t -> MetalIconFactory.getVerticalSliderThumbIcon(),
"Slider.focusInputMap", "Slider.focusInputMap",
new UIDefaults.LazyInputMap(new Object[] { new UIDefaults.LazyInputMap(new Object[] {
"RIGHT", "positiveUnitIncrement", "RIGHT", "positiveUnitIncrement",
@ -926,32 +911,29 @@ public class MetalLookAndFeel extends BasicLookAndFeel
}), }),
// Internal Frame Defaults // Internal Frame Defaults
"InternalFrame.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getInternalFrameDefaultMenuIcon"), "InternalFrame.icon",(LazyValue) t ->
"InternalFrame.border", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"), MetalIconFactory.getInternalFrameDefaultMenuIcon(),
"InternalFrame.optionDialogBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"), "InternalFrame.border",(LazyValue) t ->
"InternalFrame.paletteBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$PaletteBorder"), new MetalBorders.InternalFrameBorder(),
"InternalFrame.optionDialogBorder",(LazyValue) t ->
new MetalBorders.OptionDialogBorder(),
"InternalFrame.paletteBorder",(LazyValue) t ->
new MetalBorders.PaletteBorder(),
"InternalFrame.paletteTitleHeight", new Integer(11), "InternalFrame.paletteTitleHeight", new Integer(11),
"InternalFrame.paletteCloseIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"), "InternalFrame.paletteCloseIcon",(LazyValue) t ->
new MetalIconFactory.PaletteCloseIcon(),
"InternalFrame.closeIcon", "InternalFrame.closeIcon",
new SwingLazyValue( (LazyValue) t -> MetalIconFactory.
"javax.swing.plaf.metal.MetalIconFactory", getInternalFrameCloseIcon(internalFrameIconSize),
"getInternalFrameCloseIcon",
internalFrameIconArgs),
"InternalFrame.maximizeIcon", "InternalFrame.maximizeIcon",
new SwingLazyValue( (LazyValue) t -> MetalIconFactory.
"javax.swing.plaf.metal.MetalIconFactory", getInternalFrameMaximizeIcon(internalFrameIconSize),
"getInternalFrameMaximizeIcon",
internalFrameIconArgs),
"InternalFrame.iconifyIcon", "InternalFrame.iconifyIcon",
new SwingLazyValue( (LazyValue) t -> MetalIconFactory.
"javax.swing.plaf.metal.MetalIconFactory", getInternalFrameMinimizeIcon(internalFrameIconSize),
"getInternalFrameMinimizeIcon",
internalFrameIconArgs),
"InternalFrame.minimizeIcon", "InternalFrame.minimizeIcon",
new SwingLazyValue( (LazyValue) t -> MetalIconFactory.
"javax.swing.plaf.metal.MetalIconFactory", getInternalFrameAltMaximizeIcon(internalFrameIconSize),
"getInternalFrameAltMaximizeIcon",
internalFrameIconArgs),
"InternalFrame.titleFont", windowTitleValue, "InternalFrame.titleFont", windowTitleValue,
"InternalFrame.windowBindings", null, "InternalFrame.windowBindings", null,
// Internal Frame Auditory Cue Mappings // Internal Frame Auditory Cue Mappings
@ -1248,8 +1230,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"icons/sortDown.png"), "icons/sortDown.png"),
"TableHeader.font", userTextValue, "TableHeader.font", userTextValue,
"TableHeader.cellBorder", new SwingLazyValue( "TableHeader.cellBorder",(LazyValue) t -> new MetalBorders.TableHeaderBorder(),
"javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
// MenuBar // MenuBar
"MenuBar.border", menuBarBorder, "MenuBar.border", menuBarBorder,
@ -1271,8 +1252,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Menu.acceleratorFont", subTextValue, "Menu.acceleratorFont", subTextValue,
"Menu.acceleratorForeground", acceleratorForeground, "Menu.acceleratorForeground", acceleratorForeground,
"Menu.acceleratorSelectionForeground", acceleratorSelectedForeground, "Menu.acceleratorSelectionForeground", acceleratorSelectedForeground,
"Menu.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"), "Menu.checkIcon",(LazyValue) t -> MetalIconFactory.getMenuItemCheckIcon(),
"Menu.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuArrowIcon"), "Menu.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuArrowIcon(),
// Menu Item // Menu Item
"MenuItem.border", menuItemBorder, "MenuItem.border", menuItemBorder,
@ -1285,8 +1266,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"MenuItem.acceleratorForeground", acceleratorForeground, "MenuItem.acceleratorForeground", acceleratorForeground,
"MenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground, "MenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter, "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
"MenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"), "MenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getMenuItemCheckIcon(),
"MenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"), "MenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
// Menu Item Auditory Cue Mapping // Menu Item Auditory Cue Mapping
"MenuItem.commandSound", "sounds/MenuItemCommand.wav", "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
@ -1347,8 +1328,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"CheckBoxMenuItem.acceleratorFont", subTextValue, "CheckBoxMenuItem.acceleratorFont", subTextValue,
"CheckBoxMenuItem.acceleratorForeground", acceleratorForeground, "CheckBoxMenuItem.acceleratorForeground", acceleratorForeground,
"CheckBoxMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground, "CheckBoxMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"CheckBoxMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxMenuItemIcon"), "CheckBoxMenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getCheckBoxMenuItemIcon(),
"CheckBoxMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"), "CheckBoxMenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
"CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav", "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"RadioButtonMenuItem.border", menuItemBorder, "RadioButtonMenuItem.border", menuItemBorder,
@ -1360,8 +1341,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"RadioButtonMenuItem.acceleratorFont", subTextValue, "RadioButtonMenuItem.acceleratorFont", subTextValue,
"RadioButtonMenuItem.acceleratorForeground", acceleratorForeground, "RadioButtonMenuItem.acceleratorForeground", acceleratorForeground,
"RadioButtonMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground, "RadioButtonMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"RadioButtonMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonMenuItemIcon"), "RadioButtonMenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getRadioButtonMenuItemIcon(),
"RadioButtonMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"), "RadioButtonMenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
"RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav", "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"Spinner.ancestorInputMap", "Spinner.ancestorInputMap",
@ -1404,17 +1385,11 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Tree.font", userTextValue, "Tree.font", userTextValue,
"Tree.textBackground", getWindowBackground(), "Tree.textBackground", getWindowBackground(),
"Tree.selectionBorderColor", focusColor, "Tree.selectionBorderColor", focusColor,
"Tree.openIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"), "Tree.openIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"Tree.closedIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"), "Tree.closedIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"Tree.leafIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"), "Tree.leafIcon",(LazyValue) t -> MetalIconFactory.getTreeLeafIcon(),
"Tree.expandedIcon", new SwingLazyValue( "Tree.expandedIcon",(LazyValue) t -> MetalIconFactory.getTreeControlIcon(Boolean.valueOf(MetalIconFactory.DARK)),
"javax.swing.plaf.metal.MetalIconFactory", "Tree.collapsedIcon",(LazyValue) t -> MetalIconFactory.getTreeControlIcon(Boolean.valueOf( MetalIconFactory.LIGHT )),
"getTreeControlIcon",
new Object[] {Boolean.valueOf(MetalIconFactory.DARK)}),
"Tree.collapsedIcon", new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getTreeControlIcon",
new Object[] {Boolean.valueOf( MetalIconFactory.LIGHT )}),
"Tree.line", primaryControl, // horiz lines "Tree.line", primaryControl, // horiz lines
"Tree.hash", primaryControl, // legs "Tree.hash", primaryControl, // legs
@ -2499,4 +2474,4 @@ public class MetalLookAndFeel extends BasicLookAndFeel
return 0; return 0;
} }
} }
} }

View File

@ -32,7 +32,6 @@ import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import sun.swing.PrintColorUIResource; import sun.swing.PrintColorUIResource;
import sun.swing.SwingLazyValue;
/** /**
* The default theme for the {@code MetalLookAndFeel}. * The default theme for the {@code MetalLookAndFeel}.
@ -129,9 +128,8 @@ public class OceanTheme extends DefaultMetalTheme {
* @throws NullPointerException if {@code table} is {@code null} * @throws NullPointerException if {@code table} is {@code null}
*/ */
public void addCustomEntriesToTable(UIDefaults table) { public void addCustomEntriesToTable(UIDefaults table) {
Object focusBorder = new SwingLazyValue( UIDefaults.LazyValue focusBorder = t ->
"javax.swing.plaf.BorderUIResource$LineBorderUIResource", new BorderUIResource.LineBorderUIResource(getPrimary1());
new Object[] {getPrimary1()});
// .30 0 DDE8F3 white secondary2 // .30 0 DDE8F3 white secondary2
java.util.List buttonGradient = Arrays.asList( java.util.List buttonGradient = Arrays.asList(
new Object[] {new Float(.3f), new Float(0f), new Object[] {new Float(.3f), new Float(0f),

View File

@ -1,114 +0,0 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.swing;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import javax.swing.UIDefaults;
import sun.reflect.misc.ReflectUtil;
/**
* SwingLazyValue is a copy of ProxyLazyValue that does not snapshot the
* AccessControlContext or use a doPrivileged to resolve the class name.
* It's intented for use in places in Swing where we need ProxyLazyValue, this
* should never be used in a place where the developer could supply the
* arguments.
*
*/
public class SwingLazyValue implements UIDefaults.LazyValue {
private String className;
private String methodName;
private Object[] args;
public SwingLazyValue(String c) {
this(c, (String)null);
}
public SwingLazyValue(String c, String m) {
this(c, m, null);
}
public SwingLazyValue(String c, Object[] o) {
this(c, null, o);
}
public SwingLazyValue(String c, String m, Object[] o) {
className = c;
methodName = m;
if (o != null) {
args = o.clone();
}
}
public Object createValue(final UIDefaults table) {
try {
ReflectUtil.checkPackageAccess(className);
Class<?> c = Class.forName(className, true, null);
if (methodName != null) {
Class<?>[] types = getClassArray(args);
Method m = c.getMethod(methodName, types);
return m.invoke(c, args);
} else {
Class<?>[] types = getClassArray(args);
Constructor<?> constructor = c.getConstructor(types);
return constructor.newInstance(args);
}
} catch (Exception e) {
// Ideally we would throw an exception, unfortunately
// often times there are errors as an initial look and
// feel is loaded before one can be switched. Perhaps a
// flag should be added for debugging, so that if true
// the exception would be thrown.
}
return null;
}
private Class<?>[] getClassArray(Object[] args) {
Class<?>[] types = null;
if (args!=null) {
types = new Class<?>[args.length];
for (int i = 0; i< args.length; i++) {
/* PENDING(ges): At present only the primitive types
used are handled correctly; this should eventually
handle all primitive types */
if (args[i] instanceof java.lang.Integer) {
types[i]=Integer.TYPE;
} else if (args[i] instanceof java.lang.Boolean) {
types[i]=Boolean.TYPE;
} else if (args[i] instanceof javax.swing.plaf.ColorUIResource) {
/* PENDING(ges) Currently the Reflection APIs do not
search superclasses of parameters supplied for
constructor/method lookup. Since we only have
one case where this is needed, we substitute
directly instead of adding a massive amount
of mechanism for this. Eventually this will
probably need to handle the general case as well.
*/
types[i]=java.awt.Color.class;
} else {
types[i]=args[i].getClass();
}
}
}
return types;
}
}

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6795356
* @summary Checks that SwingLazyValue class correclty works
* @author Alexander Potochkin
* @run main SwingLazyValueTest
*/
import sun.swing.SwingLazyValue;
import javax.swing.*;
public class SwingLazyValueTest {
public static void main(String[] args) throws Exception {
if(new SwingLazyValue("javax.swing.JTable$DoubleRenderer").
createValue(null) == null) {
throw new RuntimeException("SwingLazyValue doesn't work");
}
}
}