1 /* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.swing.plaf.basic; 27 28 import java.awt.Font; 29 import java.awt.Color; 30 import java.awt.SystemColor; 31 import java.awt.event.*; 32 import java.awt.Insets; 33 import java.awt.Component; 34 import java.awt.Container; 35 import java.awt.FocusTraversalPolicy; 36 import java.awt.AWTEvent; 37 import java.awt.Toolkit; 38 import java.awt.Point; 39 import java.net.URL; 40 import java.io.*; 41 import java.awt.Dimension; 42 import java.awt.KeyboardFocusManager; 43 import java.security.AccessController; 44 import java.security.PrivilegedAction; 45 import java.util.*; 46 import java.lang.reflect.*; 47 import javax.sound.sampled.*; 48 49 import sun.awt.AppContext; 50 import sun.awt.SunToolkit; 51 52 import sun.swing.SwingLazyValue; 53 import sun.swing.SwingUtilities2; 54 55 import javax.swing.LookAndFeel; 56 import javax.swing.AbstractAction; 57 import javax.swing.Action; 58 import javax.swing.ActionMap; 59 import javax.swing.BorderFactory; 60 import javax.swing.JComponent; 61 import javax.swing.ImageIcon; 62 import javax.swing.UIDefaults; 63 import javax.swing.UIManager; 64 import javax.swing.KeyStroke; 65 import javax.swing.JTextField; 66 import javax.swing.DefaultListCellRenderer; 67 import javax.swing.FocusManager; 68 import javax.swing.LayoutFocusTraversalPolicy; 69 import javax.swing.SwingUtilities; 70 import javax.swing.MenuSelectionManager; 71 import javax.swing.MenuElement; 72 import javax.swing.border.*; 73 import javax.swing.plaf.*; 74 import javax.swing.text.JTextComponent; 75 import javax.swing.text.DefaultEditorKit; 76 import javax.swing.JInternalFrame; 77 import java.beans.PropertyVetoException; 78 import java.awt.Window; 79 import java.beans.PropertyChangeListener; 80 import java.beans.PropertyChangeEvent; 81 82 83 /** 84 * A base class to use in creating a look and feel for Swing. 85 * <p> 86 * Each of the {@code ComponentUI}s provided by {@code 87 * BasicLookAndFeel} derives its behavior from the defaults 88 * table. Unless otherwise noted each of the {@code ComponentUI} 89 * implementations in this package document the set of defaults they 90 * use. Unless otherwise noted the defaults are installed at the time 91 * {@code installUI} is invoked, and follow the recommendations 92 * outlined in {@code LookAndFeel} for installing defaults. 93 * <p> 94 * <strong>Warning:</strong> 95 * Serialized objects of this class will not be compatible with 96 * future Swing releases. The current serialization support is 97 * appropriate for short term storage or RMI between applications running 98 * the same version of Swing. As of 1.4, support for long term storage 99 * of all JavaBeans™ 100 * has been added to the <code>java.beans</code> package. 101 * Please see {@link java.beans.XMLEncoder}. 102 * 103 * @author unattributed 104 */ 105 public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable 106 { 107 /** 108 * Whether or not the developer has created a JPopupMenu. 109 */ 110 static boolean needsEventHelper; 111 112 /** 113 * Lock used when manipulating clipPlaying. 114 */ 115 private transient Object audioLock = new Object(); 116 /** 117 * The Clip that is currently playing (set in AudioAction). 118 */ 119 private Clip clipPlaying; 120 121 AWTEventHelper invocator = null; 122 123 /* 124 * Listen for our AppContext being disposed 125 */ 126 private PropertyChangeListener disposer = null; 127 128 /** 129 * Returns the look and feel defaults. The returned {@code UIDefaults} 130 * is populated by invoking, in order, {@code initClassDefaults}, 131 * {@code initSystemColorDefaults} and {@code initComponentDefaults}. 132 * <p> 133 * While this method is public, it should only be invoked by the 134 * {@code UIManager} when the look and feel is set as the current 135 * look and feel and after {@code initialize} has been invoked. 136 * 137 * @return the look and feel defaults 138 * 139 * @see #initClassDefaults 140 * @see #initSystemColorDefaults 141 * @see #initComponentDefaults 142 */ 143 public UIDefaults getDefaults() { 144 UIDefaults table = new UIDefaults(610, 0.75f); 145 146 initClassDefaults(table); 147 initSystemColorDefaults(table); 148 initComponentDefaults(table); 149 150 return table; 151 } 152 153 /** 154 * {@inheritDoc} 155 */ 156 public void initialize() { 157 if (needsEventHelper) { 158 installAWTEventListener(); 159 } 160 } 161 162 void installAWTEventListener() { 163 if (invocator == null) { 164 invocator = new AWTEventHelper(); 165 needsEventHelper = true; 166 167 // Add a PropertyChangeListener to our AppContext so we're alerted 168 // when the AppContext is disposed(), at which time this laf should 169 // be uninitialize()d. 170 disposer = new PropertyChangeListener() { 171 public void propertyChange(PropertyChangeEvent prpChg) { 172 uninitialize(); 173 } 174 }; 175 AppContext.getAppContext().addPropertyChangeListener( 176 AppContext.GUI_DISPOSED, 177 disposer); 178 } 179 } 180 181 /** 182 * {@inheritDoc} 183 */ 184 public void uninitialize() { 185 AppContext context = AppContext.getAppContext(); 186 synchronized (BasicPopupMenuUI.MOUSE_GRABBER_KEY) { 187 Object grabber = context.get(BasicPopupMenuUI.MOUSE_GRABBER_KEY); 188 if (grabber != null) { 189 ((BasicPopupMenuUI.MouseGrabber)grabber).uninstall(); 190 } 191 } 192 synchronized (BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY) { 193 Object helper = 194 context.get(BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY); 195 if (helper != null) { 196 ((BasicPopupMenuUI.MenuKeyboardHelper)helper).uninstall(); 197 } 198 } 199 200 if(invocator != null) { 201 AccessController.doPrivileged(invocator); 202 invocator = null; 203 } 204 205 if (disposer != null) { 206 // Note that we're likely calling removePropertyChangeListener() 207 // during the course of AppContext.firePropertyChange(). 208 // However, EventListenerAggreggate has code to safely modify 209 // the list under such circumstances. 210 context.removePropertyChangeListener(AppContext.GUI_DISPOSED, 211 disposer); 212 disposer = null; 213 } 214 } 215 216 /** 217 * Populates {@code table} with mappings from {@code uiClassID} to the 218 * fully qualified name of the ui class. The value for a 219 * particular {@code uiClassID} is {@code 220 * "javax.swing.plaf.basic.Basic + uiClassID"}. For example, the 221 * value for the {@code uiClassID} {@code TreeUI} is {@code 222 * "javax.swing.plaf.basic.BasicTreeUI"}. 223 * 224 * @param table the {@code UIDefaults} instance the entries are 225 * added to 226 * @throws NullPointerException if {@code table} is {@code null} 227 * 228 * @see javax.swing.LookAndFeel 229 * @see #getDefaults 230 */ 231 protected void initClassDefaults(UIDefaults table) 232 { 233 final String basicPackageName = "javax.swing.plaf.basic."; 234 Object[] uiDefaults = { 235 "ButtonUI", basicPackageName + "BasicButtonUI", 236 "CheckBoxUI", basicPackageName + "BasicCheckBoxUI", 237 "ColorChooserUI", basicPackageName + "BasicColorChooserUI", 238 "FormattedTextFieldUI", basicPackageName + "BasicFormattedTextFieldUI", 239 "MenuBarUI", basicPackageName + "BasicMenuBarUI", 240 "MenuUI", basicPackageName + "BasicMenuUI", 241 "MenuItemUI", basicPackageName + "BasicMenuItemUI", 242 "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI", 243 "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI", 244 "RadioButtonUI", basicPackageName + "BasicRadioButtonUI", 245 "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI", 246 "PopupMenuUI", basicPackageName + "BasicPopupMenuUI", 247 "ProgressBarUI", basicPackageName + "BasicProgressBarUI", 248 "ScrollBarUI", basicPackageName + "BasicScrollBarUI", 249 "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI", 250 "SplitPaneUI", basicPackageName + "BasicSplitPaneUI", 251 "SliderUI", basicPackageName + "BasicSliderUI", 252 "SeparatorUI", basicPackageName + "BasicSeparatorUI", 253 "SpinnerUI", basicPackageName + "BasicSpinnerUI", 254 "ToolBarSeparatorUI", basicPackageName + "BasicToolBarSeparatorUI", 255 "PopupMenuSeparatorUI", basicPackageName + "BasicPopupMenuSeparatorUI", 256 "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI", 257 "TextAreaUI", basicPackageName + "BasicTextAreaUI", 258 "TextFieldUI", basicPackageName + "BasicTextFieldUI", 259 "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI", 260 "TextPaneUI", basicPackageName + "BasicTextPaneUI", 261 "EditorPaneUI", basicPackageName + "BasicEditorPaneUI", 262 "TreeUI", basicPackageName + "BasicTreeUI", 263 "LabelUI", basicPackageName + "BasicLabelUI", 264 "ListUI", basicPackageName + "BasicListUI", 265 "ToolBarUI", basicPackageName + "BasicToolBarUI", 266 "ToolTipUI", basicPackageName + "BasicToolTipUI", 267 "ComboBoxUI", basicPackageName + "BasicComboBoxUI", 268 "TableUI", basicPackageName + "BasicTableUI", 269 "TableHeaderUI", basicPackageName + "BasicTableHeaderUI", 270 "InternalFrameUI", basicPackageName + "BasicInternalFrameUI", 271 "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI", 272 "DesktopIconUI", basicPackageName + "BasicDesktopIconUI", 273 "FileChooserUI", basicPackageName + "BasicFileChooserUI", 274 "OptionPaneUI", basicPackageName + "BasicOptionPaneUI", 275 "PanelUI", basicPackageName + "BasicPanelUI", 276 "ViewportUI", basicPackageName + "BasicViewportUI", 277 "RootPaneUI", basicPackageName + "BasicRootPaneUI", 278 }; 279 280 table.putDefaults(uiDefaults); 281 } 282 283 /** 284 * Populates {@code table} with system colors. This creates an 285 * array of {@code name-color} pairs and invokes {@code 286 * loadSystemColors}. 287 * <p> 288 * The name is a {@code String} that corresponds to the name of 289 * one of the static {@code SystemColor} fields in the {@code 290 * SystemColor} class. A name-color pair is created for every 291 * such {@code SystemColor} field. 292 * <p> 293 * The {@code color} corresponds to a hex {@code String} as 294 * understood by {@code Color.decode}. For example, one of the 295 * {@code name-color} pairs is {@code 296 * "desktop"-"#005C5C"}. This corresponds to the {@code 297 * SystemColor} field {@code desktop}, with a color value of 298 * {@code new Color(0x005C5C)}. 299 * <p> 300 * The following shows two of the {@code name-color} pairs: 301 * <pre> 302 * String[] nameColorPairs = new String[] { 303 * "desktop", "#005C5C", 304 * "activeCaption", "#000080" }; 305 * loadSystemColors(table, nameColorPairs, isNativeLookAndFeel()); 306 * </pre> 307 * 308 * As previously stated, this invokes {@code loadSystemColors} 309 * with the supplied {@code table} and {@code name-color} pair 310 * array. The last argument to {@code loadSystemColors} indicates 311 * whether the value of the field in {@code SystemColor} should be 312 * used. This method passes the value of {@code 313 * isNativeLookAndFeel()} as the last argument to {@code loadSystemColors}. 314 * 315 * @param table the {@code UIDefaults} object the values are added to 316 * @throws NullPointerException if {@code table} is {@code null} 317 * 318 * @see java.awt.SystemColor 319 * @see #getDefaults 320 * @see #loadSystemColors 321 */ 322 protected void initSystemColorDefaults(UIDefaults table) 323 { 324 String[] defaultSystemColors = { 325 "desktop", "#005C5C", /* Color of the desktop background */ 326 "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */ 327 "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */ 328 "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */ 329 "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */ 330 "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */ 331 "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */ 332 "window", "#FFFFFF", /* Default color for the interior of windows */ 333 "windowBorder", "#000000", /* ??? */ 334 "windowText", "#000000", /* ??? */ 335 "menu", "#C0C0C0", /* Background color for menus */ 336 "menuText", "#000000", /* Text color for menus */ 337 "text", "#C0C0C0", /* Text background color */ 338 "textText", "#000000", /* Text foreground color */ 339 "textHighlight", "#000080", /* Text background color when selected */ 340 "textHighlightText", "#FFFFFF", /* Text color when selected */ 341 "textInactiveText", "#808080", /* Text color when disabled */ 342 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */ 343 "controlText", "#000000", /* Default color for text in controls */ 344 "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */ 345 "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */ 346 "controlShadow", "#808080", /* Shadow color for controls */ 347 "controlDkShadow", "#000000", /* Dark shadow color for controls */ 348 "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */ 349 "info", "#FFFFE1", /* ??? */ 350 "infoText", "#000000" /* ??? */ 351 }; 352 353 loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel()); 354 } 355 356 357 /** 358 * Populates {@code table} with the {@code name-color} pairs in 359 * {@code systemColors}. Refer to 360 * {@link #initSystemColorDefaults(UIDefaults)} for details on 361 * the format of {@code systemColors}. 362 * <p> 363 * An entry is added to {@code table} for each of the {@code name-color} 364 * pairs in {@code systemColors}. The entry key is 365 * the {@code name} of the {@code name-color} pair. 366 * <p> 367 * The value of the entry corresponds to the {@code color} of the 368 * {@code name-color} pair. The value of the entry is calculated 369 * in one of two ways. With either approach the value is always a 370 * {@code ColorUIResource}. 371 * <p> 372 * If {@code useNative} is {@code false}, the {@code color} is 373 * created by using {@code Color.decode} to convert the {@code 374 * String} into a {@code Color}. If {@code decode} can not convert 375 * the {@code String} into a {@code Color} ({@code 376 * NumberFormatException} is thrown) then a {@code 377 * ColorUIResource} of black is used. 378 * <p> 379 * If {@code useNative} is {@code true}, the {@code color} is the 380 * value of the field in {@code SystemColor} with the same name as 381 * the {@code name} of the {@code name-color} pair. If the field 382 * is not valid, a {@code ColorUIResource} of black is used. 383 * 384 * @param table the {@code UIDefaults} object the values are added to 385 * @param systemColors array of {@code name-color} pairs as described 386 * in {@link #initSystemColorDefaults(UIDefaults)} 387 * @param useNative whether the color is obtained from {@code SystemColor} 388 * or {@code Color.decode} 389 * @throws NullPointerException if {@code systemColors} is {@code null}; or 390 * {@code systemColors} is not empty, and {@code table} is 391 * {@code null}; or one of the 392 * names of the {@code name-color} pairs is {@code null}; or 393 * {@code useNative} is {@code false} and one of the 394 * {@code colors} of the {@code name-color} pairs is {@code null} 395 * @throws ArrayIndexOutOfBoundsException if {@code useNative} is 396 * {@code false} and {@code systemColors.length} is odd 397 * 398 * @see #initSystemColorDefaults(javax.swing.UIDefaults) 399 * @see java.awt.SystemColor 400 * @see java.awt.Color#decode(String) 401 */ 402 protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative) 403 { 404 /* PENDING(hmuller) We don't load the system colors below because 405 * they're not reliable. Hopefully we'll be able to do better in 406 * a future version of AWT. 407 */ 408 if (useNative) { 409 for(int i = 0; i < systemColors.length; i += 2) { 410 Color color = Color.black; 411 try { 412 String name = systemColors[i]; 413 color = (Color)(SystemColor.class.getField(name).get(null)); 414 } catch (Exception e) { 415 } 416 table.put(systemColors[i], new ColorUIResource(color)); 417 } 418 } else { 419 for(int i = 0; i < systemColors.length; i += 2) { 420 Color color = Color.black; 421 try { 422 color = Color.decode(systemColors[i + 1]); 423 } 424 catch(NumberFormatException e) { 425 e.printStackTrace(); 426 } 427 table.put(systemColors[i], new ColorUIResource(color)); 428 } 429 } 430 } 431 /** 432 * Initialize the defaults table with the name of the ResourceBundle 433 * used for getting localized defaults. Also initialize the default 434 * locale used when no locale is passed into UIDefaults.get(). The 435 * default locale should generally not be relied upon. It is here for 436 * compatibility with releases prior to 1.4. 437 */ 438 private void initResourceBundle(UIDefaults table) { 439 table.setDefaultLocale( Locale.getDefault() ); 440 table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" ); 441 } 442 443 /** 444 * Populates {@code table} with the defaults for the basic look and 445 * feel. 446 * 447 * @param table the {@code UIDefaults} to add the values to 448 * @throws NullPointerException if {@code table} is {@code null} 449 */ 450 protected void initComponentDefaults(UIDefaults table) 451 { 452 453 initResourceBundle(table); 454 455 // *** Shared Integers 456 Integer fiveHundred = new Integer(500); 457 458 // *** Shared Longs 459 Long oneThousand = new Long(1000); 460 461 // *** Shared Fonts 462 Integer twelve = new Integer(12); 463 Integer fontPlain = new Integer(Font.PLAIN); 464 Integer fontBold = new Integer(Font.BOLD); 465 Object dialogPlain12 = new SwingLazyValue( 466 "javax.swing.plaf.FontUIResource", 467 null, 468 new Object[] {Font.DIALOG, fontPlain, twelve}); 469 Object serifPlain12 = new SwingLazyValue( 470 "javax.swing.plaf.FontUIResource", 471 null, 472 new Object[] {Font.SERIF, fontPlain, twelve}); 473 Object sansSerifPlain12 = new SwingLazyValue( 474 "javax.swing.plaf.FontUIResource", 475 null, 476 new Object[] {Font.SANS_SERIF, fontPlain, twelve}); 477 Object monospacedPlain12 = new SwingLazyValue( 478 "javax.swing.plaf.FontUIResource", 479 null, 480 new Object[] {Font.MONOSPACED, fontPlain, twelve}); 481 Object dialogBold12 = new SwingLazyValue( 482 "javax.swing.plaf.FontUIResource", 483 null, 484 new Object[] {Font.DIALOG, fontBold, twelve}); 485 486 487 // *** Shared Colors 488 ColorUIResource red = new ColorUIResource(Color.red); 489 ColorUIResource black = new ColorUIResource(Color.black); 490 ColorUIResource white = new ColorUIResource(Color.white); 491 ColorUIResource yellow = new ColorUIResource(Color.yellow); 492 ColorUIResource gray = new ColorUIResource(Color.gray); 493 ColorUIResource lightGray = new ColorUIResource(Color.lightGray); 494 ColorUIResource darkGray = new ColorUIResource(Color.darkGray); 495 ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224); 496 497 Color control = table.getColor("control"); 498 Color controlDkShadow = table.getColor("controlDkShadow"); 499 Color controlHighlight = table.getColor("controlHighlight"); 500 Color controlLtHighlight = table.getColor("controlLtHighlight"); 501 Color controlShadow = table.getColor("controlShadow"); 502 Color controlText = table.getColor("controlText"); 503 Color menu = table.getColor("menu"); 504 Color menuText = table.getColor("menuText"); 505 Color textHighlight = table.getColor("textHighlight"); 506 Color textHighlightText = table.getColor("textHighlightText"); 507 Color textInactiveText = table.getColor("textInactiveText"); 508 Color textText = table.getColor("textText"); 509 Color window = table.getColor("window"); 510 511 // *** Shared Insets 512 InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0); 513 InsetsUIResource twoInsets = new InsetsUIResource(2,2,2,2); 514 InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3); 515 516 // *** Shared Borders 517 Object marginBorder = new SwingLazyValue( 518 "javax.swing.plaf.basic.BasicBorders$MarginBorder"); 519 Object etchedBorder = new SwingLazyValue( 520 "javax.swing.plaf.BorderUIResource", 521 "getEtchedBorderUIResource"); 522 Object loweredBevelBorder = new SwingLazyValue( 523 "javax.swing.plaf.BorderUIResource", 524 "getLoweredBevelBorderUIResource"); 525 526 Object popupMenuBorder = new SwingLazyValue( 527 "javax.swing.plaf.basic.BasicBorders", 528 "getInternalFrameBorder"); 529 530 Object blackLineBorder = new SwingLazyValue( 531 "javax.swing.plaf.BorderUIResource", 532 "getBlackLineBorderUIResource"); 533 Object focusCellHighlightBorder = new SwingLazyValue( 534 "javax.swing.plaf.BorderUIResource$LineBorderUIResource", 535 null, 536 new Object[] {yellow}); 537 538 Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1); 539 540 Object tableHeaderBorder = new SwingLazyValue( 541 "javax.swing.plaf.BorderUIResource$BevelBorderUIResource", 542 null, 543 new Object[] { new Integer(BevelBorder.RAISED), 544 controlLtHighlight, 545 control, 546 controlDkShadow, 547 controlShadow }); 548 549 550 // *** Button value objects 551 552 Object buttonBorder = 553 new SwingLazyValue( 554 "javax.swing.plaf.basic.BasicBorders", 555 "getButtonBorder"); 556 557 Object buttonToggleBorder = 558 new SwingLazyValue( 559 "javax.swing.plaf.basic.BasicBorders", 560 "getToggleButtonBorder"); 561 562 Object radioButtonBorder = 563 new SwingLazyValue( 564 "javax.swing.plaf.basic.BasicBorders", 565 "getRadioButtonBorder"); 566 567 // *** FileChooser / FileView value objects 568 569 Object newFolderIcon = SwingUtilities2.makeIcon(getClass(), 570 BasicLookAndFeel.class, 571 "icons/NewFolder.gif"); 572 Object upFolderIcon = SwingUtilities2.makeIcon(getClass(), 573 BasicLookAndFeel.class, 574 "icons/UpFolder.gif"); 575 Object homeFolderIcon = SwingUtilities2.makeIcon(getClass(), 576 BasicLookAndFeel.class, 577 "icons/HomeFolder.gif"); 578 Object detailsViewIcon = SwingUtilities2.makeIcon(getClass(), 579 BasicLookAndFeel.class, 580 "icons/DetailsView.gif"); 581 Object listViewIcon = SwingUtilities2.makeIcon(getClass(), 582 BasicLookAndFeel.class, 583 "icons/ListView.gif"); 584 Object directoryIcon = SwingUtilities2.makeIcon(getClass(), 585 BasicLookAndFeel.class, 586 "icons/Directory.gif"); 587 Object fileIcon = SwingUtilities2.makeIcon(getClass(), 588 BasicLookAndFeel.class, 589 "icons/File.gif"); 590 Object computerIcon = SwingUtilities2.makeIcon(getClass(), 591 BasicLookAndFeel.class, 592 "icons/Computer.gif"); 593 Object hardDriveIcon = SwingUtilities2.makeIcon(getClass(), 594 BasicLookAndFeel.class, 595 "icons/HardDrive.gif"); 596 Object floppyDriveIcon = SwingUtilities2.makeIcon(getClass(), 597 BasicLookAndFeel.class, 598 "icons/FloppyDrive.gif"); 599 600 601 // *** InternalFrame value objects 602 603 Object internalFrameBorder = new SwingLazyValue( 604 "javax.swing.plaf.basic.BasicBorders", 605 "getInternalFrameBorder"); 606 607 // *** List value objects 608 609 Object listCellRendererActiveValue = new UIDefaults.ActiveValue() { 610 public Object createValue(UIDefaults table) { 611 return new DefaultListCellRenderer.UIResource(); 612 } 613 }; 614 615 616 // *** Menus value objects 617 618 Object menuBarBorder = 619 new SwingLazyValue( 620 "javax.swing.plaf.basic.BasicBorders", 621 "getMenuBarBorder"); 622 623 Object menuItemCheckIcon = 624 new SwingLazyValue( 625 "javax.swing.plaf.basic.BasicIconFactory", 626 "getMenuItemCheckIcon"); 627 628 Object menuItemArrowIcon = 629 new SwingLazyValue( 630 "javax.swing.plaf.basic.BasicIconFactory", 631 "getMenuItemArrowIcon"); 632 633 634 Object menuArrowIcon = 635 new SwingLazyValue( 636 "javax.swing.plaf.basic.BasicIconFactory", 637 "getMenuArrowIcon"); 638 639 Object checkBoxIcon = 640 new SwingLazyValue( 641 "javax.swing.plaf.basic.BasicIconFactory", 642 "getCheckBoxIcon"); 643 644 Object radioButtonIcon = 645 new SwingLazyValue( 646 "javax.swing.plaf.basic.BasicIconFactory", 647 "getRadioButtonIcon"); 648 649 Object checkBoxMenuItemIcon = 650 new SwingLazyValue( 651 "javax.swing.plaf.basic.BasicIconFactory", 652 "getCheckBoxMenuItemIcon"); 653 654 Object radioButtonMenuItemIcon = 655 new SwingLazyValue( 656 "javax.swing.plaf.basic.BasicIconFactory", 657 "getRadioButtonMenuItemIcon"); 658 659 Object menuItemAcceleratorDelimiter = "+"; 660 661 // *** OptionPane value objects 662 663 Object optionPaneMinimumSize = new DimensionUIResource(262, 90); 664 665 Integer zero = new Integer(0); 666 Object zeroBorder = new SwingLazyValue( 667 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 668 new Object[] {zero, zero, zero, zero}); 669 670 Integer ten = new Integer(10); 671 Object optionPaneBorder = new SwingLazyValue( 672 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 673 new Object[] {ten, ten, twelve, ten}); 674 675 Object optionPaneButtonAreaBorder = new SwingLazyValue( 676 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 677 new Object[] {new Integer(6), zero, zero, zero}); 678 679 680 // *** ProgessBar value objects 681 682 Object progressBarBorder = 683 new SwingLazyValue( 684 "javax.swing.plaf.basic.BasicBorders", 685 "getProgressBarBorder"); 686 687 // ** ScrollBar value objects 688 689 Object minimumThumbSize = new DimensionUIResource(8,8); 690 Object maximumThumbSize = new DimensionUIResource(4096,4096); 691 692 // ** Slider value objects 693 694 Object sliderFocusInsets = twoInsets; 695 696 Object toolBarSeparatorSize = new DimensionUIResource( 10, 10 ); 697 698 699 // *** SplitPane value objects 700 701 Object splitPaneBorder = 702 new SwingLazyValue( 703 "javax.swing.plaf.basic.BasicBorders", 704 "getSplitPaneBorder"); 705 Object splitPaneDividerBorder = 706 new SwingLazyValue( 707 "javax.swing.plaf.basic.BasicBorders", 708 "getSplitPaneDividerBorder"); 709 710 // ** TabbedBane value objects 711 712 Object tabbedPaneTabInsets = new InsetsUIResource(0, 4, 1, 4); 713 714 Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1); 715 716 Object tabbedPaneTabAreaInsets = new InsetsUIResource(3, 2, 0, 2); 717 718 Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 3, 3); 719 720 721 // *** Text value objects 722 723 Object textFieldBorder = 724 new SwingLazyValue( 725 "javax.swing.plaf.basic.BasicBorders", 726 "getTextFieldBorder"); 727 728 Object editorMargin = threeInsets; 729 730 Object caretBlinkRate = fiveHundred; 731 Integer four = new Integer(4); 732 733 Object[] allAuditoryCues = new Object[] { 734 "CheckBoxMenuItem.commandSound", 735 "InternalFrame.closeSound", 736 "InternalFrame.maximizeSound", 737 "InternalFrame.minimizeSound", 738 "InternalFrame.restoreDownSound", 739 "InternalFrame.restoreUpSound", 740 "MenuItem.commandSound", 741 "OptionPane.errorSound", 742 "OptionPane.informationSound", 743 "OptionPane.questionSound", 744 "OptionPane.warningSound", 745 "PopupMenu.popupSound", 746 "RadioButtonMenuItem.commandSound"}; 747 748 Object[] noAuditoryCues = new Object[] {"mute"}; 749 750 // *** Component Defaults 751 752 Object[] defaults = { 753 // *** Auditory Feedback 754 "AuditoryCues.cueList", allAuditoryCues, 755 "AuditoryCues.allAuditoryCues", allAuditoryCues, 756 "AuditoryCues.noAuditoryCues", noAuditoryCues, 757 // this key defines which of the various cues to render. 758 // L&Fs that want auditory feedback NEED to override playList. 759 "AuditoryCues.playList", null, 760 761 // *** Buttons 762 "Button.defaultButtonFollowsFocus", Boolean.TRUE, 763 "Button.font", dialogPlain12, 764 "Button.background", control, 765 "Button.foreground", controlText, 766 "Button.shadow", controlShadow, 767 "Button.darkShadow", controlDkShadow, 768 "Button.light", controlHighlight, 769 "Button.highlight", controlLtHighlight, 770 "Button.border", buttonBorder, 771 "Button.margin", new InsetsUIResource(2, 14, 2, 14), 772 "Button.textIconGap", four, 773 "Button.textShiftOffset", zero, 774 "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { 775 "SPACE", "pressed", 776 "released SPACE", "released", 777 "ENTER", "pressed", 778 "released ENTER", "released" 779 }), 780 781 "ToggleButton.font", dialogPlain12, 782 "ToggleButton.background", control, 783 "ToggleButton.foreground", controlText, 784 "ToggleButton.shadow", controlShadow, 785 "ToggleButton.darkShadow", controlDkShadow, 786 "ToggleButton.light", controlHighlight, 787 "ToggleButton.highlight", controlLtHighlight, 788 "ToggleButton.border", buttonToggleBorder, 789 "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14), 790 "ToggleButton.textIconGap", four, 791 "ToggleButton.textShiftOffset", zero, 792 "ToggleButton.focusInputMap", 793 new UIDefaults.LazyInputMap(new Object[] { 794 "SPACE", "pressed", 795 "released SPACE", "released" 796 }), 797 798 "RadioButton.font", dialogPlain12, 799 "RadioButton.background", control, 800 "RadioButton.foreground", controlText, 801 "RadioButton.shadow", controlShadow, 802 "RadioButton.darkShadow", controlDkShadow, 803 "RadioButton.light", controlHighlight, 804 "RadioButton.highlight", controlLtHighlight, 805 "RadioButton.border", radioButtonBorder, 806 "RadioButton.margin", twoInsets, 807 "RadioButton.textIconGap", four, 808 "RadioButton.textShiftOffset", zero, 809 "RadioButton.icon", radioButtonIcon, 810 "RadioButton.focusInputMap", 811 new UIDefaults.LazyInputMap(new Object[] { 812 "SPACE", "pressed", 813 "released SPACE", "released", 814 "RETURN", "pressed" 815 }), 816 817 "CheckBox.font", dialogPlain12, 818 "CheckBox.background", control, 819 "CheckBox.foreground", controlText, 820 "CheckBox.border", radioButtonBorder, 821 "CheckBox.margin", twoInsets, 822 "CheckBox.textIconGap", four, 823 "CheckBox.textShiftOffset", zero, 824 "CheckBox.icon", checkBoxIcon, 825 "CheckBox.focusInputMap", 826 new UIDefaults.LazyInputMap(new Object[] { 827 "SPACE", "pressed", 828 "released SPACE", "released" 829 }), 830 "FileChooser.useSystemExtensionHiding", Boolean.FALSE, 831 832 // *** ColorChooser 833 "ColorChooser.font", dialogPlain12, 834 "ColorChooser.background", control, 835 "ColorChooser.foreground", controlText, 836 837 "ColorChooser.swatchesSwatchSize", new Dimension(10, 10), 838 "ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10), 839 "ColorChooser.swatchesDefaultRecentColor", control, 840 841 // *** ComboBox 842 "ComboBox.font", sansSerifPlain12, 843 "ComboBox.background", window, 844 "ComboBox.foreground", textText, 845 "ComboBox.buttonBackground", control, 846 "ComboBox.buttonShadow", controlShadow, 847 "ComboBox.buttonDarkShadow", controlDkShadow, 848 "ComboBox.buttonHighlight", controlLtHighlight, 849 "ComboBox.selectionBackground", textHighlight, 850 "ComboBox.selectionForeground", textHighlightText, 851 "ComboBox.disabledBackground", control, 852 "ComboBox.disabledForeground", textInactiveText, 853 "ComboBox.timeFactor", oneThousand, 854 "ComboBox.isEnterSelectablePopup", Boolean.FALSE, 855 "ComboBox.ancestorInputMap", 856 new UIDefaults.LazyInputMap(new Object[] { 857 "ESCAPE", "hidePopup", 858 "PAGE_UP", "pageUpPassThrough", 859 "PAGE_DOWN", "pageDownPassThrough", 860 "HOME", "homePassThrough", 861 "END", "endPassThrough", 862 "ENTER", "enterPressed" 863 }), 864 "ComboBox.noActionOnKeyNavigation", Boolean.FALSE, 865 866 // *** FileChooser 867 868 "FileChooser.newFolderIcon", newFolderIcon, 869 "FileChooser.upFolderIcon", upFolderIcon, 870 "FileChooser.homeFolderIcon", homeFolderIcon, 871 "FileChooser.detailsViewIcon", detailsViewIcon, 872 "FileChooser.listViewIcon", listViewIcon, 873 "FileChooser.readOnly", Boolean.FALSE, 874 "FileChooser.usesSingleFilePane", Boolean.FALSE, 875 "FileChooser.ancestorInputMap", 876 new UIDefaults.LazyInputMap(new Object[] { 877 "ESCAPE", "cancelSelection", 878 "F5", "refresh", 879 }), 880 881 "FileView.directoryIcon", directoryIcon, 882 "FileView.fileIcon", fileIcon, 883 "FileView.computerIcon", computerIcon, 884 "FileView.hardDriveIcon", hardDriveIcon, 885 "FileView.floppyDriveIcon", floppyDriveIcon, 886 887 // *** InternalFrame 888 "InternalFrame.titleFont", dialogBold12, 889 "InternalFrame.borderColor", control, 890 "InternalFrame.borderShadow", controlShadow, 891 "InternalFrame.borderDarkShadow", controlDkShadow, 892 "InternalFrame.borderHighlight", controlLtHighlight, 893 "InternalFrame.borderLight", controlHighlight, 894 "InternalFrame.border", internalFrameBorder, 895 "InternalFrame.icon", SwingUtilities2.makeIcon(getClass(), 896 BasicLookAndFeel.class, 897 "icons/JavaCup16.png"), 898 899 /* Default frame icons are undefined for Basic. */ 900 "InternalFrame.maximizeIcon", 901 new SwingLazyValue( 902 "javax.swing.plaf.basic.BasicIconFactory", 903 "createEmptyFrameIcon"), 904 "InternalFrame.minimizeIcon", 905 new SwingLazyValue( 906 "javax.swing.plaf.basic.BasicIconFactory", 907 "createEmptyFrameIcon"), 908 "InternalFrame.iconifyIcon", 909 new SwingLazyValue( 910 "javax.swing.plaf.basic.BasicIconFactory", 911 "createEmptyFrameIcon"), 912 "InternalFrame.closeIcon", 913 new SwingLazyValue( 914 "javax.swing.plaf.basic.BasicIconFactory", 915 "createEmptyFrameIcon"), 916 // InternalFrame Auditory Cue Mappings 917 "InternalFrame.closeSound", null, 918 "InternalFrame.maximizeSound", null, 919 "InternalFrame.minimizeSound", null, 920 "InternalFrame.restoreDownSound", null, 921 "InternalFrame.restoreUpSound", null, 922 923 "InternalFrame.activeTitleBackground", table.get("activeCaption"), 924 "InternalFrame.activeTitleForeground", table.get("activeCaptionText"), 925 "InternalFrame.inactiveTitleBackground", table.get("inactiveCaption"), 926 "InternalFrame.inactiveTitleForeground", table.get("inactiveCaptionText"), 927 "InternalFrame.windowBindings", new Object[] { 928 "shift ESCAPE", "showSystemMenu", 929 "ctrl SPACE", "showSystemMenu", 930 "ESCAPE", "hideSystemMenu"}, 931 932 "InternalFrameTitlePane.iconifyButtonOpacity", Boolean.TRUE, 933 "InternalFrameTitlePane.maximizeButtonOpacity", Boolean.TRUE, 934 "InternalFrameTitlePane.closeButtonOpacity", Boolean.TRUE, 935 936 "DesktopIcon.border", internalFrameBorder, 937 938 "Desktop.minOnScreenInsets", threeInsets, 939 "Desktop.background", table.get("desktop"), 940 "Desktop.ancestorInputMap", 941 new UIDefaults.LazyInputMap(new Object[] { 942 "ctrl F5", "restore", 943 "ctrl F4", "close", 944 "ctrl F7", "move", 945 "ctrl F8", "resize", 946 "RIGHT", "right", 947 "KP_RIGHT", "right", 948 "shift RIGHT", "shrinkRight", 949 "shift KP_RIGHT", "shrinkRight", 950 "LEFT", "left", 951 "KP_LEFT", "left", 952 "shift LEFT", "shrinkLeft", 953 "shift KP_LEFT", "shrinkLeft", 954 "UP", "up", 955 "KP_UP", "up", 956 "shift UP", "shrinkUp", 957 "shift KP_UP", "shrinkUp", 958 "DOWN", "down", 959 "KP_DOWN", "down", 960 "shift DOWN", "shrinkDown", 961 "shift KP_DOWN", "shrinkDown", 962 "ESCAPE", "escape", 963 "ctrl F9", "minimize", 964 "ctrl F10", "maximize", 965 "ctrl F6", "selectNextFrame", 966 "ctrl TAB", "selectNextFrame", 967 "ctrl alt F6", "selectNextFrame", 968 "shift ctrl alt F6", "selectPreviousFrame", 969 "ctrl F12", "navigateNext", 970 "shift ctrl F12", "navigatePrevious" 971 }), 972 973 // *** Label 974 "Label.font", dialogPlain12, 975 "Label.background", control, 976 "Label.foreground", controlText, 977 "Label.disabledForeground", white, 978 "Label.disabledShadow", controlShadow, 979 "Label.border", null, 980 981 // *** List 982 "List.font", dialogPlain12, 983 "List.background", window, 984 "List.foreground", textText, 985 "List.selectionBackground", textHighlight, 986 "List.selectionForeground", textHighlightText, 987 "List.noFocusBorder", noFocusBorder, 988 "List.focusCellHighlightBorder", focusCellHighlightBorder, 989 "List.dropLineColor", controlShadow, 990 "List.border", null, 991 "List.cellRenderer", listCellRendererActiveValue, 992 "List.timeFactor", oneThousand, 993 "List.focusInputMap", 994 new UIDefaults.LazyInputMap(new Object[] { 995 "ctrl C", "copy", 996 "ctrl V", "paste", 997 "ctrl X", "cut", 998 "COPY", "copy", 999 "PASTE", "paste", 1000 "CUT", "cut", 1001 "control INSERT", "copy", 1002 "shift INSERT", "paste", 1003 "shift DELETE", "cut", 1004 "UP", "selectPreviousRow", 1005 "KP_UP", "selectPreviousRow", 1006 "shift UP", "selectPreviousRowExtendSelection", 1007 "shift KP_UP", "selectPreviousRowExtendSelection", 1008 "ctrl shift UP", "selectPreviousRowExtendSelection", 1009 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 1010 "ctrl UP", "selectPreviousRowChangeLead", 1011 "ctrl KP_UP", "selectPreviousRowChangeLead", 1012 "DOWN", "selectNextRow", 1013 "KP_DOWN", "selectNextRow", 1014 "shift DOWN", "selectNextRowExtendSelection", 1015 "shift KP_DOWN", "selectNextRowExtendSelection", 1016 "ctrl shift DOWN", "selectNextRowExtendSelection", 1017 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 1018 "ctrl DOWN", "selectNextRowChangeLead", 1019 "ctrl KP_DOWN", "selectNextRowChangeLead", 1020 "LEFT", "selectPreviousColumn", 1021 "KP_LEFT", "selectPreviousColumn", 1022 "shift LEFT", "selectPreviousColumnExtendSelection", 1023 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 1024 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 1025 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 1026 "ctrl LEFT", "selectPreviousColumnChangeLead", 1027 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 1028 "RIGHT", "selectNextColumn", 1029 "KP_RIGHT", "selectNextColumn", 1030 "shift RIGHT", "selectNextColumnExtendSelection", 1031 "shift KP_RIGHT", "selectNextColumnExtendSelection", 1032 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 1033 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 1034 "ctrl RIGHT", "selectNextColumnChangeLead", 1035 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 1036 "HOME", "selectFirstRow", 1037 "shift HOME", "selectFirstRowExtendSelection", 1038 "ctrl shift HOME", "selectFirstRowExtendSelection", 1039 "ctrl HOME", "selectFirstRowChangeLead", 1040 "END", "selectLastRow", 1041 "shift END", "selectLastRowExtendSelection", 1042 "ctrl shift END", "selectLastRowExtendSelection", 1043 "ctrl END", "selectLastRowChangeLead", 1044 "PAGE_UP", "scrollUp", 1045 "shift PAGE_UP", "scrollUpExtendSelection", 1046 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 1047 "ctrl PAGE_UP", "scrollUpChangeLead", 1048 "PAGE_DOWN", "scrollDown", 1049 "shift PAGE_DOWN", "scrollDownExtendSelection", 1050 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 1051 "ctrl PAGE_DOWN", "scrollDownChangeLead", 1052 "ctrl A", "selectAll", 1053 "ctrl SLASH", "selectAll", 1054 "ctrl BACK_SLASH", "clearSelection", 1055 "SPACE", "addToSelection", 1056 "ctrl SPACE", "toggleAndAnchor", 1057 "shift SPACE", "extendTo", 1058 "ctrl shift SPACE", "moveSelectionTo" 1059 }), 1060 "List.focusInputMap.RightToLeft", 1061 new UIDefaults.LazyInputMap(new Object[] { 1062 "LEFT", "selectNextColumn", 1063 "KP_LEFT", "selectNextColumn", 1064 "shift LEFT", "selectNextColumnExtendSelection", 1065 "shift KP_LEFT", "selectNextColumnExtendSelection", 1066 "ctrl shift LEFT", "selectNextColumnExtendSelection", 1067 "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", 1068 "ctrl LEFT", "selectNextColumnChangeLead", 1069 "ctrl KP_LEFT", "selectNextColumnChangeLead", 1070 "RIGHT", "selectPreviousColumn", 1071 "KP_RIGHT", "selectPreviousColumn", 1072 "shift RIGHT", "selectPreviousColumnExtendSelection", 1073 "shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1074 "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", 1075 "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1076 "ctrl RIGHT", "selectPreviousColumnChangeLead", 1077 "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", 1078 }), 1079 1080 // *** Menus 1081 "MenuBar.font", dialogPlain12, 1082 "MenuBar.background", menu, 1083 "MenuBar.foreground", menuText, 1084 "MenuBar.shadow", controlShadow, 1085 "MenuBar.highlight", controlLtHighlight, 1086 "MenuBar.border", menuBarBorder, 1087 "MenuBar.windowBindings", new Object[] { 1088 "F10", "takeFocus" }, 1089 1090 "MenuItem.font", dialogPlain12, 1091 "MenuItem.acceleratorFont", dialogPlain12, 1092 "MenuItem.background", menu, 1093 "MenuItem.foreground", menuText, 1094 "MenuItem.selectionForeground", textHighlightText, 1095 "MenuItem.selectionBackground", textHighlight, 1096 "MenuItem.disabledForeground", null, 1097 "MenuItem.acceleratorForeground", menuText, 1098 "MenuItem.acceleratorSelectionForeground", textHighlightText, 1099 "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter, 1100 "MenuItem.border", marginBorder, 1101 "MenuItem.borderPainted", Boolean.FALSE, 1102 "MenuItem.margin", twoInsets, 1103 "MenuItem.checkIcon", menuItemCheckIcon, 1104 "MenuItem.arrowIcon", menuItemArrowIcon, 1105 "MenuItem.commandSound", null, 1106 1107 "RadioButtonMenuItem.font", dialogPlain12, 1108 "RadioButtonMenuItem.acceleratorFont", dialogPlain12, 1109 "RadioButtonMenuItem.background", menu, 1110 "RadioButtonMenuItem.foreground", menuText, 1111 "RadioButtonMenuItem.selectionForeground", textHighlightText, 1112 "RadioButtonMenuItem.selectionBackground", textHighlight, 1113 "RadioButtonMenuItem.disabledForeground", null, 1114 "RadioButtonMenuItem.acceleratorForeground", menuText, 1115 "RadioButtonMenuItem.acceleratorSelectionForeground", textHighlightText, 1116 "RadioButtonMenuItem.border", marginBorder, 1117 "RadioButtonMenuItem.borderPainted", Boolean.FALSE, 1118 "RadioButtonMenuItem.margin", twoInsets, 1119 "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon, 1120 "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon, 1121 "RadioButtonMenuItem.commandSound", null, 1122 1123 "CheckBoxMenuItem.font", dialogPlain12, 1124 "CheckBoxMenuItem.acceleratorFont", dialogPlain12, 1125 "CheckBoxMenuItem.background", menu, 1126 "CheckBoxMenuItem.foreground", menuText, 1127 "CheckBoxMenuItem.selectionForeground", textHighlightText, 1128 "CheckBoxMenuItem.selectionBackground", textHighlight, 1129 "CheckBoxMenuItem.disabledForeground", null, 1130 "CheckBoxMenuItem.acceleratorForeground", menuText, 1131 "CheckBoxMenuItem.acceleratorSelectionForeground", textHighlightText, 1132 "CheckBoxMenuItem.border", marginBorder, 1133 "CheckBoxMenuItem.borderPainted", Boolean.FALSE, 1134 "CheckBoxMenuItem.margin", twoInsets, 1135 "CheckBoxMenuItem.checkIcon", checkBoxMenuItemIcon, 1136 "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon, 1137 "CheckBoxMenuItem.commandSound", null, 1138 1139 "Menu.font", dialogPlain12, 1140 "Menu.acceleratorFont", dialogPlain12, 1141 "Menu.background", menu, 1142 "Menu.foreground", menuText, 1143 "Menu.selectionForeground", textHighlightText, 1144 "Menu.selectionBackground", textHighlight, 1145 "Menu.disabledForeground", null, 1146 "Menu.acceleratorForeground", menuText, 1147 "Menu.acceleratorSelectionForeground", textHighlightText, 1148 "Menu.border", marginBorder, 1149 "Menu.borderPainted", Boolean.FALSE, 1150 "Menu.margin", twoInsets, 1151 "Menu.checkIcon", menuItemCheckIcon, 1152 "Menu.arrowIcon", menuArrowIcon, 1153 "Menu.menuPopupOffsetX", new Integer(0), 1154 "Menu.menuPopupOffsetY", new Integer(0), 1155 "Menu.submenuPopupOffsetX", new Integer(0), 1156 "Menu.submenuPopupOffsetY", new Integer(0), 1157 "Menu.shortcutKeys", new int[]{ 1158 SwingUtilities2.getSystemMnemonicKeyMask() 1159 }, 1160 "Menu.crossMenuMnemonic", Boolean.TRUE, 1161 // Menu.cancelMode affects the cancel menu action behaviour; 1162 // currently supports: 1163 // "hideLastSubmenu" (default) 1164 // hides the last open submenu, 1165 // and move selection one step back 1166 // "hideMenuTree" 1167 // resets selection and 1168 // hide the entire structure of open menu and its submenus 1169 "Menu.cancelMode", "hideLastSubmenu", 1170 1171 // Menu.preserveTopLevelSelection affects 1172 // the cancel menu action behaviour 1173 // if set to true then top level menu selection 1174 // will be preserved when the last popup was cancelled; 1175 // the menu itself will be unselect with the next cancel action 1176 "Menu.preserveTopLevelSelection", Boolean.FALSE, 1177 1178 // PopupMenu 1179 "PopupMenu.font", dialogPlain12, 1180 "PopupMenu.background", menu, 1181 "PopupMenu.foreground", menuText, 1182 "PopupMenu.border", popupMenuBorder, 1183 // Internal Frame Auditory Cue Mappings 1184 "PopupMenu.popupSound", null, 1185 // These window InputMap bindings are used when the Menu is 1186 // selected. 1187 "PopupMenu.selectedWindowInputMapBindings", new Object[] { 1188 "ESCAPE", "cancel", 1189 "DOWN", "selectNext", 1190 "KP_DOWN", "selectNext", 1191 "UP", "selectPrevious", 1192 "KP_UP", "selectPrevious", 1193 "LEFT", "selectParent", 1194 "KP_LEFT", "selectParent", 1195 "RIGHT", "selectChild", 1196 "KP_RIGHT", "selectChild", 1197 "ENTER", "return", 1198 "ctrl ENTER", "return", 1199 "SPACE", "return" 1200 }, 1201 "PopupMenu.selectedWindowInputMapBindings.RightToLeft", new Object[] { 1202 "LEFT", "selectChild", 1203 "KP_LEFT", "selectChild", 1204 "RIGHT", "selectParent", 1205 "KP_RIGHT", "selectParent", 1206 }, 1207 "PopupMenu.consumeEventOnClose", Boolean.FALSE, 1208 1209 // *** OptionPane 1210 // You can additionaly define OptionPane.messageFont which will 1211 // dictate the fonts used for the message, and 1212 // OptionPane.buttonFont, which defines the font for the buttons. 1213 "OptionPane.font", dialogPlain12, 1214 "OptionPane.background", control, 1215 "OptionPane.foreground", controlText, 1216 "OptionPane.messageForeground", controlText, 1217 "OptionPane.border", optionPaneBorder, 1218 "OptionPane.messageAreaBorder", zeroBorder, 1219 "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder, 1220 "OptionPane.minimumSize", optionPaneMinimumSize, 1221 "OptionPane.errorIcon", SwingUtilities2.makeIcon(getClass(), 1222 BasicLookAndFeel.class, 1223 "icons/Error.gif"), 1224 "OptionPane.informationIcon", SwingUtilities2.makeIcon(getClass(), 1225 BasicLookAndFeel.class, 1226 "icons/Inform.gif"), 1227 "OptionPane.warningIcon", SwingUtilities2.makeIcon(getClass(), 1228 BasicLookAndFeel.class, 1229 "icons/Warn.gif"), 1230 "OptionPane.questionIcon", SwingUtilities2.makeIcon(getClass(), 1231 BasicLookAndFeel.class, 1232 "icons/Question.gif"), 1233 "OptionPane.windowBindings", new Object[] { 1234 "ESCAPE", "close" }, 1235 // OptionPane Auditory Cue Mappings 1236 "OptionPane.errorSound", null, 1237 "OptionPane.informationSound", null, // Info and Plain 1238 "OptionPane.questionSound", null, 1239 "OptionPane.warningSound", null, 1240 "OptionPane.buttonClickThreshhold", fiveHundred, 1241 1242 // *** Panel 1243 "Panel.font", dialogPlain12, 1244 "Panel.background", control, 1245 "Panel.foreground", textText, 1246 1247 // *** ProgressBar 1248 "ProgressBar.font", dialogPlain12, 1249 "ProgressBar.foreground", textHighlight, 1250 "ProgressBar.background", control, 1251 "ProgressBar.selectionForeground", control, 1252 "ProgressBar.selectionBackground", textHighlight, 1253 "ProgressBar.border", progressBarBorder, 1254 "ProgressBar.cellLength", new Integer(1), 1255 "ProgressBar.cellSpacing", zero, 1256 "ProgressBar.repaintInterval", new Integer(50), 1257 "ProgressBar.cycleTime", new Integer(3000), 1258 "ProgressBar.horizontalSize", new DimensionUIResource(146, 12), 1259 "ProgressBar.verticalSize", new DimensionUIResource(12, 146), 1260 1261 // *** Separator 1262 "Separator.shadow", controlShadow, // DEPRECATED - DO NOT USE! 1263 "Separator.highlight", controlLtHighlight, // DEPRECATED - DO NOT USE! 1264 1265 "Separator.background", controlLtHighlight, 1266 "Separator.foreground", controlShadow, 1267 1268 // *** ScrollBar/ScrollPane/Viewport 1269 "ScrollBar.background", scrollBarTrack, 1270 "ScrollBar.foreground", control, 1271 "ScrollBar.track", table.get("scrollbar"), 1272 "ScrollBar.trackHighlight", controlDkShadow, 1273 "ScrollBar.thumb", control, 1274 "ScrollBar.thumbHighlight", controlLtHighlight, 1275 "ScrollBar.thumbDarkShadow", controlDkShadow, 1276 "ScrollBar.thumbShadow", controlShadow, 1277 "ScrollBar.border", null, 1278 "ScrollBar.minimumThumbSize", minimumThumbSize, 1279 "ScrollBar.maximumThumbSize", maximumThumbSize, 1280 "ScrollBar.ancestorInputMap", 1281 new UIDefaults.LazyInputMap(new Object[] { 1282 "RIGHT", "positiveUnitIncrement", 1283 "KP_RIGHT", "positiveUnitIncrement", 1284 "DOWN", "positiveUnitIncrement", 1285 "KP_DOWN", "positiveUnitIncrement", 1286 "PAGE_DOWN", "positiveBlockIncrement", 1287 "LEFT", "negativeUnitIncrement", 1288 "KP_LEFT", "negativeUnitIncrement", 1289 "UP", "negativeUnitIncrement", 1290 "KP_UP", "negativeUnitIncrement", 1291 "PAGE_UP", "negativeBlockIncrement", 1292 "HOME", "minScroll", 1293 "END", "maxScroll" 1294 }), 1295 "ScrollBar.ancestorInputMap.RightToLeft", 1296 new UIDefaults.LazyInputMap(new Object[] { 1297 "RIGHT", "negativeUnitIncrement", 1298 "KP_RIGHT", "negativeUnitIncrement", 1299 "LEFT", "positiveUnitIncrement", 1300 "KP_LEFT", "positiveUnitIncrement", 1301 }), 1302 "ScrollBar.width", new Integer(16), 1303 1304 "ScrollPane.font", dialogPlain12, 1305 "ScrollPane.background", control, 1306 "ScrollPane.foreground", controlText, 1307 "ScrollPane.border", textFieldBorder, 1308 "ScrollPane.viewportBorder", null, 1309 "ScrollPane.ancestorInputMap", 1310 new UIDefaults.LazyInputMap(new Object[] { 1311 "RIGHT", "unitScrollRight", 1312 "KP_RIGHT", "unitScrollRight", 1313 "DOWN", "unitScrollDown", 1314 "KP_DOWN", "unitScrollDown", 1315 "LEFT", "unitScrollLeft", 1316 "KP_LEFT", "unitScrollLeft", 1317 "UP", "unitScrollUp", 1318 "KP_UP", "unitScrollUp", 1319 "PAGE_UP", "scrollUp", 1320 "PAGE_DOWN", "scrollDown", 1321 "ctrl PAGE_UP", "scrollLeft", 1322 "ctrl PAGE_DOWN", "scrollRight", 1323 "ctrl HOME", "scrollHome", 1324 "ctrl END", "scrollEnd" 1325 }), 1326 "ScrollPane.ancestorInputMap.RightToLeft", 1327 new UIDefaults.LazyInputMap(new Object[] { 1328 "ctrl PAGE_UP", "scrollRight", 1329 "ctrl PAGE_DOWN", "scrollLeft", 1330 }), 1331 1332 "Viewport.font", dialogPlain12, 1333 "Viewport.background", control, 1334 "Viewport.foreground", textText, 1335 1336 // *** Slider 1337 "Slider.font", dialogPlain12, 1338 "Slider.foreground", control, 1339 "Slider.background", control, 1340 "Slider.highlight", controlLtHighlight, 1341 "Slider.tickColor", Color.black, 1342 "Slider.shadow", controlShadow, 1343 "Slider.focus", controlDkShadow, 1344 "Slider.border", null, 1345 "Slider.horizontalSize", new Dimension(200, 21), 1346 "Slider.verticalSize", new Dimension(21, 200), 1347 "Slider.minimumHorizontalSize", new Dimension(36, 21), 1348 "Slider.minimumVerticalSize", new Dimension(21, 36), 1349 "Slider.focusInsets", sliderFocusInsets, 1350 "Slider.focusInputMap", 1351 new UIDefaults.LazyInputMap(new Object[] { 1352 "RIGHT", "positiveUnitIncrement", 1353 "KP_RIGHT", "positiveUnitIncrement", 1354 "DOWN", "negativeUnitIncrement", 1355 "KP_DOWN", "negativeUnitIncrement", 1356 "PAGE_DOWN", "negativeBlockIncrement", 1357 "LEFT", "negativeUnitIncrement", 1358 "KP_LEFT", "negativeUnitIncrement", 1359 "UP", "positiveUnitIncrement", 1360 "KP_UP", "positiveUnitIncrement", 1361 "PAGE_UP", "positiveBlockIncrement", 1362 "HOME", "minScroll", 1363 "END", "maxScroll" 1364 }), 1365 "Slider.focusInputMap.RightToLeft", 1366 new UIDefaults.LazyInputMap(new Object[] { 1367 "RIGHT", "negativeUnitIncrement", 1368 "KP_RIGHT", "negativeUnitIncrement", 1369 "LEFT", "positiveUnitIncrement", 1370 "KP_LEFT", "positiveUnitIncrement", 1371 }), 1372 "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE, 1373 1374 // *** Spinner 1375 "Spinner.font", monospacedPlain12, 1376 "Spinner.background", control, 1377 "Spinner.foreground", control, 1378 "Spinner.border", textFieldBorder, 1379 "Spinner.arrowButtonBorder", null, 1380 "Spinner.arrowButtonInsets", null, 1381 "Spinner.arrowButtonSize", new Dimension(16, 5), 1382 "Spinner.ancestorInputMap", 1383 new UIDefaults.LazyInputMap(new Object[] { 1384 "UP", "increment", 1385 "KP_UP", "increment", 1386 "DOWN", "decrement", 1387 "KP_DOWN", "decrement", 1388 }), 1389 "Spinner.editorBorderPainted", Boolean.FALSE, 1390 "Spinner.editorAlignment", JTextField.TRAILING, 1391 1392 // *** SplitPane 1393 "SplitPane.background", control, 1394 "SplitPane.highlight", controlLtHighlight, 1395 "SplitPane.shadow", controlShadow, 1396 "SplitPane.darkShadow", controlDkShadow, 1397 "SplitPane.border", splitPaneBorder, 1398 "SplitPane.dividerSize", new Integer(7), 1399 "SplitPaneDivider.border", splitPaneDividerBorder, 1400 "SplitPaneDivider.draggingColor", darkGray, 1401 "SplitPane.ancestorInputMap", 1402 new UIDefaults.LazyInputMap(new Object[] { 1403 "UP", "negativeIncrement", 1404 "DOWN", "positiveIncrement", 1405 "LEFT", "negativeIncrement", 1406 "RIGHT", "positiveIncrement", 1407 "KP_UP", "negativeIncrement", 1408 "KP_DOWN", "positiveIncrement", 1409 "KP_LEFT", "negativeIncrement", 1410 "KP_RIGHT", "positiveIncrement", 1411 "HOME", "selectMin", 1412 "END", "selectMax", 1413 "F8", "startResize", 1414 "F6", "toggleFocus", 1415 "ctrl TAB", "focusOutForward", 1416 "ctrl shift TAB", "focusOutBackward" 1417 }), 1418 1419 // *** TabbedPane 1420 "TabbedPane.font", dialogPlain12, 1421 "TabbedPane.background", control, 1422 "TabbedPane.foreground", controlText, 1423 "TabbedPane.highlight", controlLtHighlight, 1424 "TabbedPane.light", controlHighlight, 1425 "TabbedPane.shadow", controlShadow, 1426 "TabbedPane.darkShadow", controlDkShadow, 1427 "TabbedPane.selected", null, 1428 "TabbedPane.focus", controlText, 1429 "TabbedPane.textIconGap", four, 1430 1431 // Causes tabs to be painted on top of the content area border. 1432 // The amount of overlap is then controlled by tabAreaInsets.bottom, 1433 // which is zero by default 1434 "TabbedPane.tabsOverlapBorder", Boolean.FALSE, 1435 "TabbedPane.selectionFollowsFocus", Boolean.TRUE, 1436 1437 "TabbedPane.labelShift", 1, 1438 "TabbedPane.selectedLabelShift", -1, 1439 "TabbedPane.tabInsets", tabbedPaneTabInsets, 1440 "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets, 1441 "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets, 1442 "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets, 1443 "TabbedPane.tabRunOverlay", new Integer(2), 1444 "TabbedPane.tabsOpaque", Boolean.TRUE, 1445 "TabbedPane.contentOpaque", Boolean.TRUE, 1446 "TabbedPane.focusInputMap", 1447 new UIDefaults.LazyInputMap(new Object[] { 1448 "RIGHT", "navigateRight", 1449 "KP_RIGHT", "navigateRight", 1450 "LEFT", "navigateLeft", 1451 "KP_LEFT", "navigateLeft", 1452 "UP", "navigateUp", 1453 "KP_UP", "navigateUp", 1454 "DOWN", "navigateDown", 1455 "KP_DOWN", "navigateDown", 1456 "ctrl DOWN", "requestFocusForVisibleComponent", 1457 "ctrl KP_DOWN", "requestFocusForVisibleComponent", 1458 }), 1459 "TabbedPane.ancestorInputMap", 1460 new UIDefaults.LazyInputMap(new Object[] { 1461 "ctrl PAGE_DOWN", "navigatePageDown", 1462 "ctrl PAGE_UP", "navigatePageUp", 1463 "ctrl UP", "requestFocus", 1464 "ctrl KP_UP", "requestFocus", 1465 }), 1466 1467 1468 // *** Table 1469 "Table.font", dialogPlain12, 1470 "Table.foreground", controlText, // cell text color 1471 "Table.background", window, // cell background color 1472 "Table.selectionForeground", textHighlightText, 1473 "Table.selectionBackground", textHighlight, 1474 "Table.dropLineColor", controlShadow, 1475 "Table.dropLineShortColor", black, 1476 "Table.gridColor", gray, // grid line color 1477 "Table.focusCellBackground", window, 1478 "Table.focusCellForeground", controlText, 1479 "Table.focusCellHighlightBorder", focusCellHighlightBorder, 1480 "Table.scrollPaneBorder", loweredBevelBorder, 1481 "Table.ancestorInputMap", 1482 new UIDefaults.LazyInputMap(new Object[] { 1483 "ctrl C", "copy", 1484 "ctrl V", "paste", 1485 "ctrl X", "cut", 1486 "COPY", "copy", 1487 "PASTE", "paste", 1488 "CUT", "cut", 1489 "control INSERT", "copy", 1490 "shift INSERT", "paste", 1491 "shift DELETE", "cut", 1492 "RIGHT", "selectNextColumn", 1493 "KP_RIGHT", "selectNextColumn", 1494 "shift RIGHT", "selectNextColumnExtendSelection", 1495 "shift KP_RIGHT", "selectNextColumnExtendSelection", 1496 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 1497 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 1498 "ctrl RIGHT", "selectNextColumnChangeLead", 1499 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 1500 "LEFT", "selectPreviousColumn", 1501 "KP_LEFT", "selectPreviousColumn", 1502 "shift LEFT", "selectPreviousColumnExtendSelection", 1503 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 1504 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 1505 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 1506 "ctrl LEFT", "selectPreviousColumnChangeLead", 1507 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 1508 "DOWN", "selectNextRow", 1509 "KP_DOWN", "selectNextRow", 1510 "shift DOWN", "selectNextRowExtendSelection", 1511 "shift KP_DOWN", "selectNextRowExtendSelection", 1512 "ctrl shift DOWN", "selectNextRowExtendSelection", 1513 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 1514 "ctrl DOWN", "selectNextRowChangeLead", 1515 "ctrl KP_DOWN", "selectNextRowChangeLead", 1516 "UP", "selectPreviousRow", 1517 "KP_UP", "selectPreviousRow", 1518 "shift UP", "selectPreviousRowExtendSelection", 1519 "shift KP_UP", "selectPreviousRowExtendSelection", 1520 "ctrl shift UP", "selectPreviousRowExtendSelection", 1521 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 1522 "ctrl UP", "selectPreviousRowChangeLead", 1523 "ctrl KP_UP", "selectPreviousRowChangeLead", 1524 "HOME", "selectFirstColumn", 1525 "shift HOME", "selectFirstColumnExtendSelection", 1526 "ctrl shift HOME", "selectFirstRowExtendSelection", 1527 "ctrl HOME", "selectFirstRow", 1528 "END", "selectLastColumn", 1529 "shift END", "selectLastColumnExtendSelection", 1530 "ctrl shift END", "selectLastRowExtendSelection", 1531 "ctrl END", "selectLastRow", 1532 "PAGE_UP", "scrollUpChangeSelection", 1533 "shift PAGE_UP", "scrollUpExtendSelection", 1534 "ctrl shift PAGE_UP", "scrollLeftExtendSelection", 1535 "ctrl PAGE_UP", "scrollLeftChangeSelection", 1536 "PAGE_DOWN", "scrollDownChangeSelection", 1537 "shift PAGE_DOWN", "scrollDownExtendSelection", 1538 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", 1539 "ctrl PAGE_DOWN", "scrollRightChangeSelection", 1540 "TAB", "selectNextColumnCell", 1541 "shift TAB", "selectPreviousColumnCell", 1542 "ENTER", "selectNextRowCell", 1543 "shift ENTER", "selectPreviousRowCell", 1544 "ctrl A", "selectAll", 1545 "ctrl SLASH", "selectAll", 1546 "ctrl BACK_SLASH", "clearSelection", 1547 "ESCAPE", "cancel", 1548 "F2", "startEditing", 1549 "SPACE", "addToSelection", 1550 "ctrl SPACE", "toggleAndAnchor", 1551 "shift SPACE", "extendTo", 1552 "ctrl shift SPACE", "moveSelectionTo", 1553 "F8", "focusHeader" 1554 }), 1555 "Table.ancestorInputMap.RightToLeft", 1556 new UIDefaults.LazyInputMap(new Object[] { 1557 "RIGHT", "selectPreviousColumn", 1558 "KP_RIGHT", "selectPreviousColumn", 1559 "shift RIGHT", "selectPreviousColumnExtendSelection", 1560 "shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1561 "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", 1562 "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1563 "ctrl RIGHT", "selectPreviousColumnChangeLead", 1564 "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", 1565 "LEFT", "selectNextColumn", 1566 "KP_LEFT", "selectNextColumn", 1567 "shift LEFT", "selectNextColumnExtendSelection", 1568 "shift KP_LEFT", "selectNextColumnExtendSelection", 1569 "ctrl shift LEFT", "selectNextColumnExtendSelection", 1570 "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", 1571 "ctrl LEFT", "selectNextColumnChangeLead", 1572 "ctrl KP_LEFT", "selectNextColumnChangeLead", 1573 "ctrl PAGE_UP", "scrollRightChangeSelection", 1574 "ctrl PAGE_DOWN", "scrollLeftChangeSelection", 1575 "ctrl shift PAGE_UP", "scrollRightExtendSelection", 1576 "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection", 1577 }), 1578 "Table.ascendingSortIcon", new SwingLazyValue( 1579 "sun.swing.icon.SortArrowIcon", 1580 null, new Object[] { Boolean.TRUE, 1581 "Table.sortIconColor" }), 1582 "Table.descendingSortIcon", new SwingLazyValue( 1583 "sun.swing.icon.SortArrowIcon", 1584 null, new Object[] { Boolean.FALSE, 1585 "Table.sortIconColor" }), 1586 "Table.sortIconColor", controlShadow, 1587 1588 "TableHeader.font", dialogPlain12, 1589 "TableHeader.foreground", controlText, // header text color 1590 "TableHeader.background", control, // header background 1591 "TableHeader.cellBorder", tableHeaderBorder, 1592 1593 // Support for changing the background/border of the currently 1594 // selected header column when the header has the keyboard focus. 1595 "TableHeader.focusCellBackground", table.getColor("text"), // like text component bg 1596 "TableHeader.focusCellForeground", null, 1597 "TableHeader.focusCellBorder", null, 1598 "TableHeader.ancestorInputMap", 1599 new UIDefaults.LazyInputMap(new Object[] { 1600 "SPACE", "toggleSortOrder", 1601 "LEFT", "selectColumnToLeft", 1602 "KP_LEFT", "selectColumnToLeft", 1603 "RIGHT", "selectColumnToRight", 1604 "KP_RIGHT", "selectColumnToRight", 1605 "alt LEFT", "moveColumnLeft", 1606 "alt KP_LEFT", "moveColumnLeft", 1607 "alt RIGHT", "moveColumnRight", 1608 "alt KP_RIGHT", "moveColumnRight", 1609 "alt shift LEFT", "resizeLeft", 1610 "alt shift KP_LEFT", "resizeLeft", 1611 "alt shift RIGHT", "resizeRight", 1612 "alt shift KP_RIGHT", "resizeRight", 1613 "ESCAPE", "focusTable", 1614 }), 1615 1616 // *** Text 1617 "TextField.font", sansSerifPlain12, 1618 "TextField.background", window, 1619 "TextField.foreground", textText, 1620 "TextField.shadow", controlShadow, 1621 "TextField.darkShadow", controlDkShadow, 1622 "TextField.light", controlHighlight, 1623 "TextField.highlight", controlLtHighlight, 1624 "TextField.inactiveForeground", textInactiveText, 1625 "TextField.inactiveBackground", control, 1626 "TextField.selectionBackground", textHighlight, 1627 "TextField.selectionForeground", textHighlightText, 1628 "TextField.caretForeground", textText, 1629 "TextField.caretBlinkRate", caretBlinkRate, 1630 "TextField.border", textFieldBorder, 1631 "TextField.margin", zeroInsets, 1632 1633 "FormattedTextField.font", sansSerifPlain12, 1634 "FormattedTextField.background", window, 1635 "FormattedTextField.foreground", textText, 1636 "FormattedTextField.inactiveForeground", textInactiveText, 1637 "FormattedTextField.inactiveBackground", control, 1638 "FormattedTextField.selectionBackground", textHighlight, 1639 "FormattedTextField.selectionForeground", textHighlightText, 1640 "FormattedTextField.caretForeground", textText, 1641 "FormattedTextField.caretBlinkRate", caretBlinkRate, 1642 "FormattedTextField.border", textFieldBorder, 1643 "FormattedTextField.margin", zeroInsets, 1644 "FormattedTextField.focusInputMap", 1645 new UIDefaults.LazyInputMap(new Object[] { 1646 "ctrl C", DefaultEditorKit.copyAction, 1647 "ctrl V", DefaultEditorKit.pasteAction, 1648 "ctrl X", DefaultEditorKit.cutAction, 1649 "COPY", DefaultEditorKit.copyAction, 1650 "PASTE", DefaultEditorKit.pasteAction, 1651 "CUT", DefaultEditorKit.cutAction, 1652 "control INSERT", DefaultEditorKit.copyAction, 1653 "shift INSERT", DefaultEditorKit.pasteAction, 1654 "shift DELETE", DefaultEditorKit.cutAction, 1655 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 1656 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 1657 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 1658 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 1659 "ctrl LEFT", DefaultEditorKit.previousWordAction, 1660 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 1661 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 1662 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 1663 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 1664 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 1665 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 1666 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 1667 "ctrl A", DefaultEditorKit.selectAllAction, 1668 "HOME", DefaultEditorKit.beginLineAction, 1669 "END", DefaultEditorKit.endLineAction, 1670 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 1671 "shift END", DefaultEditorKit.selectionEndLineAction, 1672 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1673 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1674 "ctrl H", DefaultEditorKit.deletePrevCharAction, 1675 "DELETE", DefaultEditorKit.deleteNextCharAction, 1676 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, 1677 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, 1678 "RIGHT", DefaultEditorKit.forwardAction, 1679 "LEFT", DefaultEditorKit.backwardAction, 1680 "KP_RIGHT", DefaultEditorKit.forwardAction, 1681 "KP_LEFT", DefaultEditorKit.backwardAction, 1682 "ENTER", JTextField.notifyAction, 1683 "ctrl BACK_SLASH", "unselect", 1684 "control shift O", "toggle-componentOrientation", 1685 "ESCAPE", "reset-field-edit", 1686 "UP", "increment", 1687 "KP_UP", "increment", 1688 "DOWN", "decrement", 1689 "KP_DOWN", "decrement", 1690 }), 1691 1692 "PasswordField.font", monospacedPlain12, 1693 "PasswordField.background", window, 1694 "PasswordField.foreground", textText, 1695 "PasswordField.inactiveForeground", textInactiveText, 1696 "PasswordField.inactiveBackground", control, 1697 "PasswordField.selectionBackground", textHighlight, 1698 "PasswordField.selectionForeground", textHighlightText, 1699 "PasswordField.caretForeground", textText, 1700 "PasswordField.caretBlinkRate", caretBlinkRate, 1701 "PasswordField.border", textFieldBorder, 1702 "PasswordField.margin", zeroInsets, 1703 "PasswordField.echoChar", '*', 1704 1705 "TextArea.font", monospacedPlain12, 1706 "TextArea.background", window, 1707 "TextArea.foreground", textText, 1708 "TextArea.inactiveForeground", textInactiveText, 1709 "TextArea.selectionBackground", textHighlight, 1710 "TextArea.selectionForeground", textHighlightText, 1711 "TextArea.caretForeground", textText, 1712 "TextArea.caretBlinkRate", caretBlinkRate, 1713 "TextArea.border", marginBorder, 1714 "TextArea.margin", zeroInsets, 1715 1716 "TextPane.font", serifPlain12, 1717 "TextPane.background", white, 1718 "TextPane.foreground", textText, 1719 "TextPane.selectionBackground", textHighlight, 1720 "TextPane.selectionForeground", textHighlightText, 1721 "TextPane.caretForeground", textText, 1722 "TextPane.caretBlinkRate", caretBlinkRate, 1723 "TextPane.inactiveForeground", textInactiveText, 1724 "TextPane.border", marginBorder, 1725 "TextPane.margin", editorMargin, 1726 1727 "EditorPane.font", serifPlain12, 1728 "EditorPane.background", white, 1729 "EditorPane.foreground", textText, 1730 "EditorPane.selectionBackground", textHighlight, 1731 "EditorPane.selectionForeground", textHighlightText, 1732 "EditorPane.caretForeground", textText, 1733 "EditorPane.caretBlinkRate", caretBlinkRate, 1734 "EditorPane.inactiveForeground", textInactiveText, 1735 "EditorPane.border", marginBorder, 1736 "EditorPane.margin", editorMargin, 1737 1738 "html.pendingImage", SwingUtilities2.makeIcon(getClass(), 1739 BasicLookAndFeel.class, 1740 "icons/image-delayed.png"), 1741 "html.missingImage", SwingUtilities2.makeIcon(getClass(), 1742 BasicLookAndFeel.class, 1743 "icons/image-failed.png"), 1744 // *** TitledBorder 1745 "TitledBorder.font", dialogPlain12, 1746 "TitledBorder.titleColor", controlText, 1747 "TitledBorder.border", etchedBorder, 1748 1749 // *** ToolBar 1750 "ToolBar.font", dialogPlain12, 1751 "ToolBar.background", control, 1752 "ToolBar.foreground", controlText, 1753 "ToolBar.shadow", controlShadow, 1754 "ToolBar.darkShadow", controlDkShadow, 1755 "ToolBar.light", controlHighlight, 1756 "ToolBar.highlight", controlLtHighlight, 1757 "ToolBar.dockingBackground", control, 1758 "ToolBar.dockingForeground", red, 1759 "ToolBar.floatingBackground", control, 1760 "ToolBar.floatingForeground", darkGray, 1761 "ToolBar.border", etchedBorder, 1762 "ToolBar.separatorSize", toolBarSeparatorSize, 1763 "ToolBar.ancestorInputMap", 1764 new UIDefaults.LazyInputMap(new Object[] { 1765 "UP", "navigateUp", 1766 "KP_UP", "navigateUp", 1767 "DOWN", "navigateDown", 1768 "KP_DOWN", "navigateDown", 1769 "LEFT", "navigateLeft", 1770 "KP_LEFT", "navigateLeft", 1771 "RIGHT", "navigateRight", 1772 "KP_RIGHT", "navigateRight" 1773 }), 1774 1775 // *** ToolTips 1776 "ToolTip.font", sansSerifPlain12, 1777 "ToolTip.background", table.get("info"), 1778 "ToolTip.foreground", table.get("infoText"), 1779 "ToolTip.border", blackLineBorder, 1780 // ToolTips also support backgroundInactive, borderInactive, 1781 // and foregroundInactive 1782 1783 // *** ToolTipManager 1784 // ToolTipManager.enableToolTipMode currently supports: 1785 // "allWindows" (default): 1786 // enables tool tips for all windows of all java applications, 1787 // whether the windows are active or inactive 1788 // "activeApplication" 1789 // enables tool tips for windows of an application only when 1790 // the application has an active window 1791 "ToolTipManager.enableToolTipMode", "allWindows", 1792 1793 // *** Tree 1794 "Tree.paintLines", Boolean.TRUE, 1795 "Tree.lineTypeDashed", Boolean.FALSE, 1796 "Tree.font", dialogPlain12, 1797 "Tree.background", window, 1798 "Tree.foreground", textText, 1799 "Tree.hash", gray, 1800 "Tree.textForeground", textText, 1801 "Tree.textBackground", table.get("text"), 1802 "Tree.selectionForeground", textHighlightText, 1803 "Tree.selectionBackground", textHighlight, 1804 "Tree.selectionBorderColor", black, 1805 "Tree.dropLineColor", controlShadow, 1806 "Tree.editorBorder", blackLineBorder, 1807 "Tree.leftChildIndent", new Integer(7), 1808 "Tree.rightChildIndent", new Integer(13), 1809 "Tree.rowHeight", new Integer(16), 1810 "Tree.scrollsOnExpand", Boolean.TRUE, 1811 "Tree.openIcon", SwingUtilities2.makeIcon(getClass(), 1812 BasicLookAndFeel.class, 1813 "icons/TreeOpen.gif"), 1814 "Tree.closedIcon", SwingUtilities2.makeIcon(getClass(), 1815 BasicLookAndFeel.class, 1816 "icons/TreeClosed.gif"), 1817 "Tree.leafIcon", SwingUtilities2.makeIcon(getClass(), 1818 BasicLookAndFeel.class, 1819 "icons/TreeLeaf.gif"), 1820 "Tree.expandedIcon", null, 1821 "Tree.collapsedIcon", null, 1822 "Tree.changeSelectionWithFocus", Boolean.TRUE, 1823 "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE, 1824 "Tree.timeFactor", oneThousand, 1825 "Tree.focusInputMap", 1826 new UIDefaults.LazyInputMap(new Object[] { 1827 "ctrl C", "copy", 1828 "ctrl V", "paste", 1829 "ctrl X", "cut", 1830 "COPY", "copy", 1831 "PASTE", "paste", 1832 "CUT", "cut", 1833 "control INSERT", "copy", 1834 "shift INSERT", "paste", 1835 "shift DELETE", "cut", 1836 "UP", "selectPrevious", 1837 "KP_UP", "selectPrevious", 1838 "shift UP", "selectPreviousExtendSelection", 1839 "shift KP_UP", "selectPreviousExtendSelection", 1840 "ctrl shift UP", "selectPreviousExtendSelection", 1841 "ctrl shift KP_UP", "selectPreviousExtendSelection", 1842 "ctrl UP", "selectPreviousChangeLead", 1843 "ctrl KP_UP", "selectPreviousChangeLead", 1844 "DOWN", "selectNext", 1845 "KP_DOWN", "selectNext", 1846 "shift DOWN", "selectNextExtendSelection", 1847 "shift KP_DOWN", "selectNextExtendSelection", 1848 "ctrl shift DOWN", "selectNextExtendSelection", 1849 "ctrl shift KP_DOWN", "selectNextExtendSelection", 1850 "ctrl DOWN", "selectNextChangeLead", 1851 "ctrl KP_DOWN", "selectNextChangeLead", 1852 "RIGHT", "selectChild", 1853 "KP_RIGHT", "selectChild", 1854 "LEFT", "selectParent", 1855 "KP_LEFT", "selectParent", 1856 "PAGE_UP", "scrollUpChangeSelection", 1857 "shift PAGE_UP", "scrollUpExtendSelection", 1858 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 1859 "ctrl PAGE_UP", "scrollUpChangeLead", 1860 "PAGE_DOWN", "scrollDownChangeSelection", 1861 "shift PAGE_DOWN", "scrollDownExtendSelection", 1862 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 1863 "ctrl PAGE_DOWN", "scrollDownChangeLead", 1864 "HOME", "selectFirst", 1865 "shift HOME", "selectFirstExtendSelection", 1866 "ctrl shift HOME", "selectFirstExtendSelection", 1867 "ctrl HOME", "selectFirstChangeLead", 1868 "END", "selectLast", 1869 "shift END", "selectLastExtendSelection", 1870 "ctrl shift END", "selectLastExtendSelection", 1871 "ctrl END", "selectLastChangeLead", 1872 "F2", "startEditing", 1873 "ctrl A", "selectAll", 1874 "ctrl SLASH", "selectAll", 1875 "ctrl BACK_SLASH", "clearSelection", 1876 "ctrl LEFT", "scrollLeft", 1877 "ctrl KP_LEFT", "scrollLeft", 1878 "ctrl RIGHT", "scrollRight", 1879 "ctrl KP_RIGHT", "scrollRight", 1880 "SPACE", "addToSelection", 1881 "ctrl SPACE", "toggleAndAnchor", 1882 "shift SPACE", "extendTo", 1883 "ctrl shift SPACE", "moveSelectionTo" 1884 }), 1885 "Tree.focusInputMap.RightToLeft", 1886 new UIDefaults.LazyInputMap(new Object[] { 1887 "RIGHT", "selectParent", 1888 "KP_RIGHT", "selectParent", 1889 "LEFT", "selectChild", 1890 "KP_LEFT", "selectChild", 1891 }), 1892 "Tree.ancestorInputMap", 1893 new UIDefaults.LazyInputMap(new Object[] { 1894 "ESCAPE", "cancel" 1895 }), 1896 // Bind specific keys that can invoke popup on currently 1897 // focused JComponent 1898 "RootPane.ancestorInputMap", 1899 new UIDefaults.LazyInputMap(new Object[] { 1900 "shift F10", "postPopup", 1901 "CONTEXT_MENU", "postPopup" 1902 }), 1903 1904 // These bindings are only enabled when there is a default 1905 // button set on the rootpane. 1906 "RootPane.defaultButtonWindowKeyBindings", new Object[] { 1907 "ENTER", "press", 1908 "released ENTER", "release", 1909 "ctrl ENTER", "press", 1910 "ctrl released ENTER", "release" 1911 }, 1912 }; 1913 1914 table.putDefaults(defaults); 1915 } 1916 1917 static int getFocusAcceleratorKeyMask() { 1918 Toolkit tk = Toolkit.getDefaultToolkit(); 1919 if (tk instanceof SunToolkit) { 1920 return ((SunToolkit)tk).getFocusAcceleratorKeyMask(); 1921 } 1922 return ActionEvent.ALT_MASK; 1923 } 1924 1925 1926 1927 /** 1928 * Returns the ui that is of type <code>klass</code>, or null if 1929 * one can not be found. 1930 */ 1931 static Object getUIOfType(ComponentUI ui, Class klass) { 1932 if (klass.isInstance(ui)) { 1933 return ui; 1934 } 1935 return null; 1936 } 1937 1938 // ********* Auditory Cue support methods and objects ********* 1939 // also see the "AuditoryCues" section of the defaults table 1940 1941 /** 1942 * Returns an <code>ActionMap</code> containing the audio actions 1943 * for this look and feel. 1944 * <P> 1945 * The returned <code>ActionMap</code> contains <code>Actions</code> that 1946 * embody the ability to render an auditory cue. These auditory 1947 * cues map onto user and system activities that may be useful 1948 * for an end user to know about (such as a dialog box appearing). 1949 * <P> 1950 * At the appropriate time, 1951 * the {@code ComponentUI} is responsible for obtaining an 1952 * <code>Action</code> out of the <code>ActionMap</code> and passing 1953 * it to <code>playSound</code>. 1954 * <P> 1955 * This method first looks up the {@code ActionMap} from the 1956 * defaults using the key {@code "AuditoryCues.actionMap"}. 1957 * <p> 1958 * If the value is {@code non-null}, it is returned. If the value 1959 * of the default {@code "AuditoryCues.actionMap"} is {@code null} 1960 * and the value of the default {@code "AuditoryCues.cueList"} is 1961 * {@code non-null}, an {@code ActionMapUIResource} is created and 1962 * populated. Population is done by iterating over each of the 1963 * elements of the {@code "AuditoryCues.cueList"} array, and 1964 * invoking {@code createAudioAction()} to create an {@code 1965 * Action} for each element. The resulting {@code Action} is 1966 * placed in the {@code ActionMapUIResource}, using the array 1967 * element as the key. For example, if the {@code 1968 * "AuditoryCues.cueList"} array contains a single-element, {@code 1969 * "audioKey"}, the {@code ActionMapUIResource} is created, then 1970 * populated by way of {@code actionMap.put(cueList[0], 1971 * createAudioAction(cueList[0]))}. 1972 * <p> 1973 * If the value of the default {@code "AuditoryCues.actionMap"} is 1974 * {@code null} and the value of the default 1975 * {@code "AuditoryCues.cueList"} is {@code null}, an empty 1976 * {@code ActionMapUIResource} is created. 1977 * 1978 * 1979 * @return an ActionMap containing {@code Actions} 1980 * responsible for playing auditory cues 1981 * @throws ClassCastException if the value of the 1982 * default {@code "AuditoryCues.actionMap"} is not an 1983 * {@code ActionMap}, or the value of the default 1984 * {@code "AuditoryCues.cueList"} is not an {@code Object[]} 1985 * @see #createAudioAction 1986 * @see #playSound(Action) 1987 * @since 1.4 1988 */ 1989 protected ActionMap getAudioActionMap() { 1990 ActionMap audioActionMap = (ActionMap)UIManager.get( 1991 "AuditoryCues.actionMap"); 1992 if (audioActionMap == null) { 1993 Object[] acList = (Object[])UIManager.get("AuditoryCues.cueList"); 1994 if (acList != null) { 1995 audioActionMap = new ActionMapUIResource(); 1996 for(int counter = acList.length-1; counter >= 0; counter--) { 1997 audioActionMap.put(acList[counter], 1998 createAudioAction(acList[counter])); 1999 } 2000 } 2001 UIManager.getLookAndFeelDefaults().put("AuditoryCues.actionMap", 2002 audioActionMap); 2003 } 2004 return audioActionMap; 2005 } 2006 2007 /** 2008 * Creates and returns an {@code Action} used to play a sound. 2009 * <p> 2010 * If {@code key} is {@code non-null}, an {@code Action} is created 2011 * using the value from the defaults with key {@code key}. The value 2012 * identifies the sound resource to load when 2013 * {@code actionPerformed} is invoked on the {@code Action}. The 2014 * sound resource is loaded into a {@code byte[]} by way of 2015 * {@code getClass().getResourceAsStream()}. 2016 * 2017 * @param key the key identifying the audio action 2018 * @return an {@code Action} used to play the source, or {@code null} 2019 * if {@code key} is {@code null} 2020 * @see #playSound(Action) 2021 * @since 1.4 2022 */ 2023 protected Action createAudioAction(Object key) { 2024 if (key != null) { 2025 String audioKey = (String)key; 2026 String audioValue = (String)UIManager.get(key); 2027 return new AudioAction(audioKey, audioValue); 2028 } else { 2029 return null; 2030 } 2031 } 2032 2033 /** 2034 * Pass the name String to the super constructor. This is used 2035 * later to identify the Action and decide whether to play it or 2036 * not. Store the resource String. I is used to get the audio 2037 * resource. In this case, the resource is an audio file. 2038 * 2039 * @since 1.4 2040 */ 2041 private class AudioAction extends AbstractAction implements LineListener { 2042 // We strive to only play one sound at a time (other platforms 2043 // appear to do this). This is done by maintaining the field 2044 // clipPlaying. Every time a sound is to be played, 2045 // cancelCurrentSound is invoked to cancel any sound that may be 2046 // playing. 2047 private String audioResource; 2048 private byte[] audioBuffer; 2049 2050 /** 2051 * The String is the name of the Action and 2052 * points to the audio resource. 2053 * The byte[] is a buffer of the audio bits. 2054 */ 2055 public AudioAction(String name, String resource) { 2056 super(name); 2057 audioResource = resource; 2058 } 2059 2060 public void actionPerformed(ActionEvent e) { 2061 if (audioBuffer == null) { 2062 audioBuffer = loadAudioData(audioResource); 2063 } 2064 if (audioBuffer != null) { 2065 cancelCurrentSound(null); 2066 try { 2067 AudioInputStream soundStream = 2068 AudioSystem.getAudioInputStream( 2069 new ByteArrayInputStream(audioBuffer)); 2070 DataLine.Info info = 2071 new DataLine.Info(Clip.class, soundStream.getFormat()); 2072 Clip clip = (Clip) AudioSystem.getLine(info); 2073 clip.open(soundStream); 2074 clip.addLineListener(this); 2075 2076 synchronized(audioLock) { 2077 clipPlaying = clip; 2078 } 2079 2080 clip.start(); 2081 } catch (Exception ex) {} 2082 } 2083 } 2084 2085 public void update(LineEvent event) { 2086 if (event.getType() == LineEvent.Type.STOP) { 2087 cancelCurrentSound((Clip)event.getLine()); 2088 } 2089 } 2090 2091 /** 2092 * If the parameter is null, or equal to the currently 2093 * playing sound, then cancel the currently playing sound. 2094 */ 2095 private void cancelCurrentSound(Clip clip) { 2096 Clip lastClip = null; 2097 2098 synchronized(audioLock) { 2099 if (clip == null || clip == clipPlaying) { 2100 lastClip = clipPlaying; 2101 clipPlaying = null; 2102 } 2103 } 2104 2105 if (lastClip != null) { 2106 lastClip.removeLineListener(this); 2107 lastClip.close(); 2108 } 2109 } 2110 } 2111 2112 /** 2113 * Utility method that loads audio bits for the specified 2114 * <code>soundFile</code> filename. If this method is unable to 2115 * build a viable path name from the <code>baseClass</code> and 2116 * <code>soundFile</code> passed into this method, it will 2117 * return <code>null</code>. 2118 * 2119 * @param soundFile the name of the audio file to be retrieved 2120 * from disk 2121 * @return A byte[] with audio data or null 2122 * @since 1.4 2123 */ 2124 private byte[] loadAudioData(final String soundFile){ 2125 if (soundFile == null) { 2126 return null; 2127 } 2128 /* Copy resource into a byte array. This is 2129 * necessary because several browsers consider 2130 * Class.getResource a security risk since it 2131 * can be used to load additional classes. 2132 * Class.getResourceAsStream just returns raw 2133 * bytes, which we can convert to a sound. 2134 */ 2135 byte[] buffer = AccessController.doPrivileged( 2136 new PrivilegedAction<byte[]>() { 2137 public byte[] run() { 2138 try { 2139 InputStream resource = BasicLookAndFeel.this. 2140 getClass().getResourceAsStream(soundFile); 2141 if (resource == null) { 2142 return null; 2143 } 2144 BufferedInputStream in = 2145 new BufferedInputStream(resource); 2146 ByteArrayOutputStream out = 2147 new ByteArrayOutputStream(1024); 2148 byte[] buffer = new byte[1024]; 2149 int n; 2150 while ((n = in.read(buffer)) > 0) { 2151 out.write(buffer, 0, n); 2152 } 2153 in.close(); 2154 out.flush(); 2155 buffer = out.toByteArray(); 2156 return buffer; 2157 } catch (IOException ioe) { 2158 System.err.println(ioe.toString()); 2159 return null; 2160 } 2161 } 2162 }); 2163 if (buffer == null) { 2164 System.err.println(getClass().getName() + "/" + 2165 soundFile + " not found."); 2166 return null; 2167 } 2168 if (buffer.length == 0) { 2169 System.err.println("warning: " + soundFile + 2170 " is zero-length"); 2171 return null; 2172 } 2173 return buffer; 2174 } 2175 2176 /** 2177 * If necessary, invokes {@code actionPerformed} on 2178 * {@code audioAction} to play a sound. 2179 * The {@code actionPerformed} method is invoked if the value of 2180 * the {@code "AuditoryCues.playList"} default is a {@code 2181 * non-null} {@code Object[]} containing a {@code String} entry 2182 * equal to the name of the {@code audioAction}. 2183 * 2184 * @param audioAction an Action that knows how to render the audio 2185 * associated with the system or user activity 2186 * that is occurring; a value of {@code null}, is 2187 * ignored 2188 * @throws ClassCastException if {@code audioAction} is {@code non-null} 2189 * and the value of the default {@code "AuditoryCues.playList"} 2190 * is not an {@code Object[]} 2191 * @since 1.4 2192 */ 2193 protected void playSound(Action audioAction) { 2194 if (audioAction != null) { 2195 Object[] audioStrings = (Object[]) 2196 UIManager.get("AuditoryCues.playList"); 2197 if (audioStrings != null) { 2198 // create a HashSet to help us decide to play or not 2199 HashSet<Object> audioCues = new HashSet<Object>(); 2200 for (Object audioString : audioStrings) { 2201 audioCues.add(audioString); 2202 } 2203 // get the name of the Action 2204 String actionName = (String)audioAction.getValue(Action.NAME); 2205 // if the actionName is in the audioCues HashSet, play it. 2206 if (audioCues.contains(actionName)) { 2207 audioAction.actionPerformed(new 2208 ActionEvent(this, ActionEvent.ACTION_PERFORMED, 2209 actionName)); 2210 } 2211 } 2212 } 2213 } 2214 2215 2216 /** 2217 * Sets the parent of the passed in ActionMap to be the audio action 2218 * map. 2219 */ 2220 static void installAudioActionMap(ActionMap map) { 2221 LookAndFeel laf = UIManager.getLookAndFeel(); 2222 if (laf instanceof BasicLookAndFeel) { 2223 map.setParent(((BasicLookAndFeel)laf).getAudioActionMap()); 2224 } 2225 } 2226 2227 2228 /** 2229 * Helper method to play a named sound. 2230 * 2231 * @param c JComponent to play the sound for. 2232 * @param actionKey Key for the sound. 2233 */ 2234 static void playSound(JComponent c, Object actionKey) { 2235 LookAndFeel laf = UIManager.getLookAndFeel(); 2236 if (laf instanceof BasicLookAndFeel) { 2237 ActionMap map = c.getActionMap(); 2238 if (map != null) { 2239 Action audioAction = map.get(actionKey); 2240 if (audioAction != null) { 2241 // pass off firing the Action to a utility method 2242 ((BasicLookAndFeel)laf).playSound(audioAction); 2243 } 2244 } 2245 } 2246 } 2247 2248 /** 2249 * This class contains listener that watches for all the mouse 2250 * events that can possibly invoke popup on the component 2251 */ 2252 class AWTEventHelper implements AWTEventListener,PrivilegedAction<Object> { 2253 AWTEventHelper() { 2254 super(); 2255 AccessController.doPrivileged(this); 2256 } 2257 2258 public Object run() { 2259 Toolkit tk = Toolkit.getDefaultToolkit(); 2260 if(invocator == null) { 2261 tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); 2262 } else { 2263 tk.removeAWTEventListener(invocator); 2264 } 2265 // Return value not used. 2266 return null; 2267 } 2268 2269 public void eventDispatched(AWTEvent ev) { 2270 int eventID = ev.getID(); 2271 if((eventID & AWTEvent.MOUSE_EVENT_MASK) != 0) { 2272 MouseEvent me = (MouseEvent) ev; 2273 if(me.isPopupTrigger()) { 2274 MenuElement[] elems = MenuSelectionManager 2275 .defaultManager() 2276 .getSelectedPath(); 2277 if(elems != null && elems.length != 0) { 2278 return; 2279 // We shall not interfere with already opened menu 2280 } 2281 Object c = me.getSource(); 2282 JComponent src = null; 2283 if(c instanceof JComponent) { 2284 src = (JComponent) c; 2285 } else if(c instanceof BasicSplitPaneDivider) { 2286 // Special case - if user clicks on divider we must 2287 // invoke popup from the SplitPane 2288 src = (JComponent) 2289 ((BasicSplitPaneDivider)c).getParent(); 2290 } 2291 if(src != null) { 2292 if(src.getComponentPopupMenu() != null) { 2293 Point pt = src.getPopupLocation(me); 2294 if(pt == null) { 2295 pt = me.getPoint(); 2296 pt = SwingUtilities.convertPoint((Component)c, 2297 pt, src); 2298 } 2299 src.getComponentPopupMenu().show(src, pt.x, pt.y); 2300 me.consume(); 2301 } 2302 } 2303 } 2304 } 2305 /* Activate a JInternalFrame if necessary. */ 2306 if (eventID == MouseEvent.MOUSE_PRESSED) { 2307 Object object = ev.getSource(); 2308 if (!(object instanceof Component)) { 2309 return; 2310 } 2311 Component component = (Component)object; 2312 if (component != null) { 2313 Component parent = component; 2314 while (parent != null && !(parent instanceof Window)) { 2315 if (parent instanceof JInternalFrame) { 2316 // Activate the frame. 2317 try { ((JInternalFrame)parent).setSelected(true); } 2318 catch (PropertyVetoException e1) { } 2319 } 2320 parent = parent.getParent(); 2321 } 2322 } 2323 } 2324 } 2325 } 2326 }