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

View File

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

View File

@ -52,6 +52,7 @@ import javax.swing.*;
import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import javax.swing.text.DefaultEditorKit;
import static javax.swing.UIDefaults.LazyValue;
import java.awt.Font;
import java.awt.Color;
@ -67,9 +68,10 @@ import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle;
import sun.swing.ImageIconUIResource;
import sun.swing.SwingLazyValue;
import sun.swing.icon.SortArrowIcon;
import sun.swing.SwingUtilities2;
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.XPStyle.Skin;
@ -296,27 +298,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
initResourceBundle(table);
// *** Shared Fonts
Integer twelve = Integer.valueOf(12);
Integer fontPlain = Integer.valueOf(Font.PLAIN);
Integer fontBold = Integer.valueOf(Font.BOLD);
LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
Object dialogPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
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});
LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
// *** Colors
// 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,
WindowBackgroundColor),
"FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource")),
(LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
"FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
"icons/ListView.gif"),
"FileChooser.listViewWindowsStyle", Boolean.TRUE,
@ -849,15 +833,12 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"InternalFrame.closeIcon",
WindowsIconFactory.createFrameCloseIcon(),
"InternalFrame.icon",
new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane$ScalableIconUIResource",
(LazyValue) t -> new Object[]{
// The constructor takes one arg: an array of UIDefaults.LazyValue
// representing the icons
new Object[][] { {
SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
} }),
},
// Internal Frame Auditory Cue Mappings
"InternalFrame.closeSound", "win.sound.close",
"InternalFrame.maximizeSound", "win.sound.maximize",
@ -1715,9 +1696,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
String POPUP_MENU_BORDER = "PopupMenu.border";
Object popupMenuBorder = new XPBorderValue(Part.MENU,
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder"),
(LazyValue) t -> BasicBorders.getInternalFrameBorder(),
BorderFactory.createEmptyBorder(2, 2, 2, 2));
table.put(POPUP_MENU_BORDER, popupMenuBorder);
/* END handling menus for Vista */
@ -1725,14 +1704,10 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
/* START table handling for Vista */
table.put("Table.ascendingSortIcon", new XPValue(
new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.TRUE })));
(LazyValue) t -> new ClassicSortArrowIcon(true)));
table.put("Table.descendingSortIcon", new XPValue(
new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.FALSE })));
(LazyValue) t -> new ClassicSortArrowIcon(false)));
/* END table handling for Vista */
}
@ -1757,15 +1732,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object buttonBorder =
new XPBorderValue(Part.BP_PUSHBUTTON,
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getButtonBorder"));
(LazyValue) t -> BasicBorders.getButtonBorder());
Object textFieldBorder =
new XPBorderValue(Part.EP_EDIT,
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getTextFieldBorder"));
(LazyValue) t -> BasicBorders.getTextFieldBorder());
Object textFieldMargin =
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);
// For focus rectangle for cells and trees.
Object focusCellHighlightBorder = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getFocusCellHighlightBorder");
LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
Object etchedBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getEtchedBorderUIResource");
LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
Object internalFrameBorder = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getInternalFrameBorder");
LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
Object loweredBevelBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource");
LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
Object marginBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders$MarginBorder");
LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
Object menuBarBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getMenuBarBorder");
LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
Object popupMenuBorder = new XPBorderValue(Part.MENU,
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder"));
(LazyValue) t -> BasicBorders.getInternalFrameBorder());
// *** ProgressBar
Object progressBarBorder = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getProgressBarBorder");
LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
Object radioButtonBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getRadioButtonBorder");
LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
Object scrollPaneBorder =
new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
@ -1827,45 +1781,27 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object tableScrollPaneBorder =
new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
Object tableHeaderBorder = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getTableHeaderBorder");
LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
// *** ToolBar
Object toolBarBorder = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsBorders",
"getToolBarBorder");
LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
// *** ToolTips
Object toolTipBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getBlackLineBorderUIResource");
LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
Object checkBoxIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getCheckBoxIcon");
LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
Object radioButtonIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getRadioButtonIcon");
LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
Object radioButtonMenuItemIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getRadioButtonMenuItemIcon");
LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
Object menuItemCheckIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuItemCheckIcon");
LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
Object menuItemArrowIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuItemArrowIcon");
LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
Object menuArrowIcon = new SwingLazyValue(
"com.sun.java.swing.plaf.windows.WindowsIconFactory",
"getMenuArrowIcon");
LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
Object[] lazyDefaults = {
@ -1910,21 +1846,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"InternalFrame.layoutTitlePaneAtOrigin",
new XPValue(Boolean.TRUE, Boolean.FALSE),
"Table.ascendingSortIcon", new XPValue(
new SwingLazyValue(
"sun.swing.icon.SortArrowIcon",
null, new Object[] { Boolean.TRUE,
"Table.sortIconColor" }),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.TRUE })),
(LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
(LazyValue) t -> new ClassicSortArrowIcon(true)),
"Table.descendingSortIcon", new XPValue(
new SwingLazyValue(
"sun.swing.icon.SortArrowIcon",
null, new Object[] { Boolean.FALSE,
"Table.sortIconColor" }),
new SwingLazyValue(
"sun.swing.plaf.windows.ClassicSortArrowIcon",
null, new Object[] { Boolean.FALSE })),
(LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
(LazyValue) t -> new ClassicSortArrowIcon(false)),
};
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 static sun.swing.SwingUtilities2.Section.*;
import sun.swing.PrintingStatus;
import sun.swing.SwingLazyValue;
/**
* 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.SunToolkit;
import sun.swing.SwingLazyValue;
import sun.swing.SwingUtilities2;
import sun.swing.icon.SortArrowIcon;
import javax.swing.LookAndFeel;
import javax.swing.AbstractAction;
@ -74,6 +74,7 @@ import javax.swing.plaf.*;
import javax.swing.text.JTextComponent;
import javax.swing.text.DefaultEditorKit;
import javax.swing.JInternalFrame;
import static javax.swing.UIDefaults.LazyValue;
import java.beans.PropertyVetoException;
import java.awt.Window;
import java.beans.PropertyChangeListener;
@ -459,30 +460,16 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Shared Longs
Long oneThousand = new Long(1000);
// *** Shared Fonts
Integer twelve = new Integer(12);
Integer fontPlain = new Integer(Font.PLAIN);
Integer fontBold = new Integer(Font.BOLD);
Object dialogPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
null,
new Object[] {Font.DIALOG, fontPlain, twelve});
Object serifPlain12 = new SwingLazyValue(
"javax.swing.plaf.FontUIResource",
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});
LazyValue dialogPlain12 = t ->
new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
LazyValue serifPlain12 = t ->
new FontUIResource(Font.SERIF, Font.PLAIN, 12);
LazyValue sansSerifPlain12 = t ->
new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
LazyValue monospacedPlain12 = t ->
new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
LazyValue dialogBold12 = t ->
new FontUIResource(Font.DIALOG, Font.BOLD, 12);
// *** Shared Colors
@ -515,55 +502,40 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3);
// *** Shared Borders
Object marginBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders$MarginBorder");
Object etchedBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getEtchedBorderUIResource");
Object loweredBevelBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getLoweredBevelBorderUIResource");
LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
LazyValue etchedBorder = t ->
BorderUIResource.getEtchedBorderUIResource();
LazyValue loweredBevelBorder = t ->
BorderUIResource.getLoweredBevelBorderUIResource();
Object popupMenuBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder");
LazyValue popupMenuBorder = t -> BasicBorders.getInternalFrameBorder();
Object blackLineBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource",
"getBlackLineBorderUIResource");
Object focusCellHighlightBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
null,
new Object[] {yellow});
LazyValue blackLineBorder = t ->
BorderUIResource.getBlackLineBorderUIResource();
LazyValue focusCellHighlightBorder = t ->
new BorderUIResource.LineBorderUIResource(yellow);
Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1);
Object tableHeaderBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$BevelBorderUIResource",
null,
new Object[] { new Integer(BevelBorder.RAISED),
LazyValue tableHeaderBorder = t ->
new BorderUIResource.BevelBorderUIResource(
BevelBorder.RAISED,
controlLtHighlight,
control,
controlDkShadow,
controlShadow });
controlShadow);
// *** Button value objects
Object buttonBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getButtonBorder");
LazyValue buttonBorder =
t -> BasicBorders.getButtonBorder();
Object buttonToggleBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getToggleButtonBorder");
LazyValue buttonToggleBorder =
t -> BasicBorders.getToggleButtonBorder();
Object radioButtonBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getRadioButtonBorder");
LazyValue radioButtonBorder =
t -> BasicBorders.getRadioButtonBorder();
// *** FileChooser / FileView value objects
@ -601,9 +573,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** InternalFrame value objects
Object internalFrameBorder = new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getInternalFrameBorder");
LazyValue internalFrameBorder = t ->
BasicBorders.getInternalFrameBorder();
// *** List value objects
@ -616,46 +587,30 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Menus value objects
Object menuBarBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getMenuBarBorder");
LazyValue menuBarBorder =
t -> BasicBorders.getMenuBarBorder();
Object menuItemCheckIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuItemCheckIcon");
LazyValue menuItemCheckIcon =
t -> BasicIconFactory.getMenuItemCheckIcon();
Object menuItemArrowIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuItemArrowIcon");
LazyValue menuItemArrowIcon =
t -> BasicIconFactory.getMenuItemArrowIcon();
Object menuArrowIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getMenuArrowIcon");
LazyValue menuArrowIcon =
t -> BasicIconFactory.getMenuArrowIcon();
Object checkBoxIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getCheckBoxIcon");
LazyValue checkBoxIcon =
t -> BasicIconFactory.getCheckBoxIcon();
Object radioButtonIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getRadioButtonIcon");
LazyValue radioButtonIcon =
t -> BasicIconFactory.getRadioButtonIcon();
Object checkBoxMenuItemIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getCheckBoxMenuItemIcon");
LazyValue checkBoxMenuItemIcon =
t -> BasicIconFactory.getCheckBoxMenuItemIcon();
Object radioButtonMenuItemIcon =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"getRadioButtonMenuItemIcon");
LazyValue radioButtonMenuItemIcon =
t -> BasicIconFactory.getRadioButtonMenuItemIcon();
Object menuItemAcceleratorDelimiter = "+";
@ -663,27 +618,22 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
Object optionPaneMinimumSize = new DimensionUIResource(262, 90);
Integer zero = new Integer(0);
Object zeroBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
new Object[] {zero, zero, zero, zero});
int zero = 0;
LazyValue zeroBorder = t ->
new BorderUIResource.EmptyBorderUIResource(zero, zero, zero, zero);
Integer ten = new Integer(10);
Object optionPaneBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
new Object[] {ten, ten, twelve, ten});
int ten = 10;
LazyValue optionPaneBorder = t ->
new BorderUIResource.EmptyBorderUIResource(ten, ten, 12, ten);
Object optionPaneButtonAreaBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
new Object[] {new Integer(6), zero, zero, zero});
LazyValue optionPaneButtonAreaBorder = t ->
new BorderUIResource.EmptyBorderUIResource(6, zero, zero, zero);
// *** ProgessBar value objects
Object progressBarBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getProgressBarBorder");
LazyValue progressBarBorder =
t -> BasicBorders.getProgressBarBorder();
// ** ScrollBar value objects
@ -699,14 +649,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** SplitPane value objects
Object splitPaneBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getSplitPaneBorder");
Object splitPaneDividerBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getSplitPaneDividerBorder");
LazyValue splitPaneBorder =
t -> BasicBorders.getSplitPaneBorder();
LazyValue splitPaneDividerBorder =
t -> BasicBorders.getSplitPaneDividerBorder();
// ** TabbedBane value objects
@ -721,10 +667,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
// *** Text value objects
Object textFieldBorder =
new SwingLazyValue(
"javax.swing.plaf.basic.BasicBorders",
"getTextFieldBorder");
LazyValue textFieldBorder =
t -> BasicBorders.getTextFieldBorder();
Object editorMargin = threeInsets;
@ -899,21 +843,13 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
/* Default frame icons are undefined for Basic. */
"InternalFrame.maximizeIcon",
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
(LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.minimizeIcon",
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
(LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.iconifyIcon",
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
(LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.closeIcon",
new SwingLazyValue(
"javax.swing.plaf.basic.BasicIconFactory",
"createEmptyFrameIcon"),
(LazyValue) t -> BasicIconFactory.createEmptyFrameIcon(),
// InternalFrame Auditory Cue Mappings
"InternalFrame.closeSound", null,
"InternalFrame.maximizeSound", null,
@ -1576,14 +1512,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
"ctrl shift PAGE_UP", "scrollRightExtendSelection",
"ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
}),
"Table.ascendingSortIcon", new SwingLazyValue(
"sun.swing.icon.SortArrowIcon",
null, new Object[] { Boolean.TRUE,
"Table.sortIconColor" }),
"Table.descendingSortIcon", new SwingLazyValue(
"sun.swing.icon.SortArrowIcon",
null, new Object[] { Boolean.FALSE,
"Table.sortIconColor" }),
"Table.ascendingSortIcon", (LazyValue) t ->
new SortArrowIcon(true, "Table.sortIconColor"),
"Table.descendingSortIcon", (LazyValue) t ->
new SortArrowIcon(false, "Table.sortIconColor"),
"Table.sortIconColor", controlShadow,
"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.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle;
import sun.swing.SwingLazyValue;
import static javax.swing.UIDefaults.LazyValue;
import sun.swing.SwingUtilities2;
/**
@ -457,9 +457,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
Integer zero = Integer.valueOf(0);
Object textFieldBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
"getTextFieldBorder");
LazyValue textFieldBorder =
t -> MetalBorders.getTextFieldBorder();
Object dialogBorder = new MetalLazyValue(
"javax.swing.plaf.metal.MetalBorders$DialogBorder");
@ -614,61 +613,47 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
});
Object scrollPaneBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder");
Object buttonBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
"getButtonBorder");
LazyValue scrollPaneBorder = t -> new MetalBorders.ScrollPaneBorder();
LazyValue buttonBorder =
t -> MetalBorders.getButtonBorder();
Object toggleButtonBorder =
new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
"getToggleButtonBorder");
LazyValue toggleButtonBorder =
t -> MetalBorders.getToggleButtonBorder();
Object titledBorderBorder =
new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {controlShadow});
LazyValue titledBorderBorder =
t -> new BorderUIResource.LineBorderUIResource(controlShadow);
Object desktopIconBorder =
new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders",
"getDesktopIconBorder");
LazyValue desktopIconBorder =
t -> MetalBorders.getDesktopIconBorder();
Object menuBarBorder =
new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
LazyValue menuBarBorder =
t -> new MetalBorders.MenuBarBorder();
Object popupMenuBorder =
new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders$PopupMenuBorder");
Object menuItemBorder =
new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
LazyValue popupMenuBorder =
t -> new MetalBorders.PopupMenuBorder();
LazyValue menuItemBorder =
t -> new MetalBorders.MenuItemBorder();
Object menuItemAcceleratorDelimiter = "-";
Object toolBarBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ToolBarBorder");
LazyValue toolBarBorder = t -> new MetalBorders.ToolBarBorder();
Object progressBarBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {controlDarkShadow, new Integer(1)});
LazyValue progressBarBorder = t ->
new BorderUIResource.LineBorderUIResource(controlDarkShadow, new Integer(1));
Object toolTipBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {primaryControlDarkShadow});
LazyValue toolTipBorder = t ->
new BorderUIResource.LineBorderUIResource(primaryControlDarkShadow);
Object toolTipBorderInactive = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {controlDarkShadow});
LazyValue toolTipBorderInactive = t ->
new BorderUIResource.LineBorderUIResource(controlDarkShadow);
Object focusCellHighlightBorder = new SwingLazyValue(
"javax.swing.plaf.BorderUIResource$LineBorderUIResource",
new Object[] {focusColor});
LazyValue focusCellHighlightBorder = t ->
new BorderUIResource.LineBorderUIResource(focusColor);
Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6);
Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
final Object[] internalFrameIconArgs = new Object[1];
internalFrameIconArgs[0] = new Integer(16);
int internalFrameIconSize = 16;
Object[] defaultCueList = new Object[] {
"OptionPane.errorSound",
@ -794,7 +779,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Checkbox.select", controlShadow,
"CheckBox.font", controlTextValue,
"CheckBox.focus", focusColor,
"CheckBox.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxIcon"),
"CheckBox.icon",(LazyValue) t -> MetalIconFactory.getCheckBoxIcon(),
"CheckBox.focusInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"SPACE", "pressed",
@ -806,7 +791,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"RadioButton.disabledText", inactiveControlTextColor,
"RadioButton.select", controlShadow,
"RadioButton.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonIcon"),
"RadioButton.icon",(LazyValue) t -> MetalIconFactory.getRadioButtonIcon(),
"RadioButton.font", controlTextValue,
"RadioButton.focus", focusColor,
"RadioButton.focusInputMap",
@ -831,18 +816,18 @@ public class MetalLookAndFeel extends BasicLookAndFeel
// File View
"FileView.directoryIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
"FileView.fileIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
"FileView.computerIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeComputerIcon"),
"FileView.hardDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeHardDriveIcon"),
"FileView.floppyDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFloppyDriveIcon"),
"FileView.directoryIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"FileView.fileIcon",(LazyValue) t -> MetalIconFactory.getTreeLeafIcon(),
"FileView.computerIcon",(LazyValue) t -> MetalIconFactory.getTreeComputerIcon(),
"FileView.hardDriveIcon",(LazyValue) t -> MetalIconFactory.getTreeHardDriveIcon(),
"FileView.floppyDriveIcon",(LazyValue) t -> MetalIconFactory.getTreeFloppyDriveIcon(),
// File Chooser
"FileChooser.detailsViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserDetailViewIcon"),
"FileChooser.homeFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserHomeFolderIcon"),
"FileChooser.listViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserListViewIcon"),
"FileChooser.newFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserNewFolderIcon"),
"FileChooser.upFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserUpFolderIcon"),
"FileChooser.detailsViewIcon",(LazyValue) t -> MetalIconFactory.getFileChooserDetailViewIcon(),
"FileChooser.homeFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserHomeFolderIcon(),
"FileChooser.listViewIcon",(LazyValue) t -> MetalIconFactory.getFileChooserListViewIcon(),
"FileChooser.newFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserNewFolderIcon(),
"FileChooser.upFolderIcon",(LazyValue) t -> MetalIconFactory.getFileChooserUpFolderIcon(),
"FileChooser.usesSingleFilePane", Boolean.TRUE,
"FileChooser.ancestorInputMap",
@ -873,8 +858,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Slider.focusInsets", zeroInsets,
"Slider.trackWidth", new Integer( 7 ),
"Slider.majorTickLength", new Integer( 6 ),
"Slider.horizontalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getHorizontalSliderThumbIcon"),
"Slider.verticalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getVerticalSliderThumbIcon"),
"Slider.horizontalThumbIcon",(LazyValue) t -> MetalIconFactory.getHorizontalSliderThumbIcon(),
"Slider.verticalThumbIcon",(LazyValue) t -> MetalIconFactory.getVerticalSliderThumbIcon(),
"Slider.focusInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"RIGHT", "positiveUnitIncrement",
@ -926,32 +911,29 @@ public class MetalLookAndFeel extends BasicLookAndFeel
}),
// Internal Frame Defaults
"InternalFrame.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getInternalFrameDefaultMenuIcon"),
"InternalFrame.border", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"),
"InternalFrame.optionDialogBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"),
"InternalFrame.paletteBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$PaletteBorder"),
"InternalFrame.icon",(LazyValue) t ->
MetalIconFactory.getInternalFrameDefaultMenuIcon(),
"InternalFrame.border",(LazyValue) t ->
new MetalBorders.InternalFrameBorder(),
"InternalFrame.optionDialogBorder",(LazyValue) t ->
new MetalBorders.OptionDialogBorder(),
"InternalFrame.paletteBorder",(LazyValue) t ->
new MetalBorders.PaletteBorder(),
"InternalFrame.paletteTitleHeight", new Integer(11),
"InternalFrame.paletteCloseIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"),
"InternalFrame.paletteCloseIcon",(LazyValue) t ->
new MetalIconFactory.PaletteCloseIcon(),
"InternalFrame.closeIcon",
new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getInternalFrameCloseIcon",
internalFrameIconArgs),
(LazyValue) t -> MetalIconFactory.
getInternalFrameCloseIcon(internalFrameIconSize),
"InternalFrame.maximizeIcon",
new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getInternalFrameMaximizeIcon",
internalFrameIconArgs),
(LazyValue) t -> MetalIconFactory.
getInternalFrameMaximizeIcon(internalFrameIconSize),
"InternalFrame.iconifyIcon",
new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getInternalFrameMinimizeIcon",
internalFrameIconArgs),
(LazyValue) t -> MetalIconFactory.
getInternalFrameMinimizeIcon(internalFrameIconSize),
"InternalFrame.minimizeIcon",
new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getInternalFrameAltMaximizeIcon",
internalFrameIconArgs),
(LazyValue) t -> MetalIconFactory.
getInternalFrameAltMaximizeIcon(internalFrameIconSize),
"InternalFrame.titleFont", windowTitleValue,
"InternalFrame.windowBindings", null,
// Internal Frame Auditory Cue Mappings
@ -1248,8 +1230,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"icons/sortDown.png"),
"TableHeader.font", userTextValue,
"TableHeader.cellBorder", new SwingLazyValue(
"javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
"TableHeader.cellBorder",(LazyValue) t -> new MetalBorders.TableHeaderBorder(),
// MenuBar
"MenuBar.border", menuBarBorder,
@ -1271,8 +1252,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Menu.acceleratorFont", subTextValue,
"Menu.acceleratorForeground", acceleratorForeground,
"Menu.acceleratorSelectionForeground", acceleratorSelectedForeground,
"Menu.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
"Menu.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuArrowIcon"),
"Menu.checkIcon",(LazyValue) t -> MetalIconFactory.getMenuItemCheckIcon(),
"Menu.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuArrowIcon(),
// Menu Item
"MenuItem.border", menuItemBorder,
@ -1285,8 +1266,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"MenuItem.acceleratorForeground", acceleratorForeground,
"MenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
"MenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
"MenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
"MenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getMenuItemCheckIcon(),
"MenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
// Menu Item Auditory Cue Mapping
"MenuItem.commandSound", "sounds/MenuItemCommand.wav",
@ -1347,8 +1328,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"CheckBoxMenuItem.acceleratorFont", subTextValue,
"CheckBoxMenuItem.acceleratorForeground", acceleratorForeground,
"CheckBoxMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"CheckBoxMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxMenuItemIcon"),
"CheckBoxMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
"CheckBoxMenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getCheckBoxMenuItemIcon(),
"CheckBoxMenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
"CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"RadioButtonMenuItem.border", menuItemBorder,
@ -1360,8 +1341,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"RadioButtonMenuItem.acceleratorFont", subTextValue,
"RadioButtonMenuItem.acceleratorForeground", acceleratorForeground,
"RadioButtonMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
"RadioButtonMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonMenuItemIcon"),
"RadioButtonMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
"RadioButtonMenuItem.checkIcon",(LazyValue) t -> MetalIconFactory.getRadioButtonMenuItemIcon(),
"RadioButtonMenuItem.arrowIcon",(LazyValue) t -> MetalIconFactory.getMenuItemArrowIcon(),
"RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"Spinner.ancestorInputMap",
@ -1404,17 +1385,11 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Tree.font", userTextValue,
"Tree.textBackground", getWindowBackground(),
"Tree.selectionBorderColor", focusColor,
"Tree.openIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
"Tree.closedIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
"Tree.leafIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
"Tree.expandedIcon", new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getTreeControlIcon",
new Object[] {Boolean.valueOf(MetalIconFactory.DARK)}),
"Tree.collapsedIcon", new SwingLazyValue(
"javax.swing.plaf.metal.MetalIconFactory",
"getTreeControlIcon",
new Object[] {Boolean.valueOf( MetalIconFactory.LIGHT )}),
"Tree.openIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"Tree.closedIcon",(LazyValue) t -> MetalIconFactory.getTreeFolderIcon(),
"Tree.leafIcon",(LazyValue) t -> MetalIconFactory.getTreeLeafIcon(),
"Tree.expandedIcon",(LazyValue) t -> MetalIconFactory.getTreeControlIcon(Boolean.valueOf(MetalIconFactory.DARK)),
"Tree.collapsedIcon",(LazyValue) t -> MetalIconFactory.getTreeControlIcon(Boolean.valueOf( MetalIconFactory.LIGHT )),
"Tree.line", primaryControl, // horiz lines
"Tree.hash", primaryControl, // legs
@ -2499,4 +2474,4 @@ public class MetalLookAndFeel extends BasicLookAndFeel
return 0;
}
}
}
}

View File

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