001 /* 002 * $Id: ContextMenuAuxLF.java,v 1.5 2006/03/30 10:19:12 kleopatra Exp $ 003 * 004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 005 * Santa Clara, California 95054, U.S.A. All rights reserved. 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 020 */ 021 package org.jdesktop.swingx.plaf; 022 023 import javax.swing.LookAndFeel; 024 import javax.swing.UIDefaults; 025 026 /** 027 * Support for context dependent popup menus. 028 * 029 * It's meant to be used as a auxiliary LF on top of main LF: 030 * 031 * <pre> 032 * <code> 033 * UIManager.addAuxiliaryLookAndFeel(new ContextMenuAuxLF()); 034 * </code> 035 * </pre> 036 * 037 * There are core-issues involved, which might or might not 038 * impair its usefulness, for details please see a thread in 039 * the SwingLabs forum: <p> 040 * 041 * <a href="http://forums.java.net/jive/thread.jspa?threadID=7713"> 042 * Experimental: default context menus for textcomponents/scrollbars 043 * </a> 044 * 045 * 046 * @author Jeanette Winzenburg 047 */ 048 public class ContextMenuAuxLF extends LookAndFeel { 049 050 private UIDefaults myDefaults; 051 052 public String getName() { 053 return "ContextMenuAuxLF"; 054 } 055 056 public String getID() { 057 return getName(); 058 } 059 060 public String getDescription() { 061 062 return "Auxiliary LF to Support Context Dependent Popups"; 063 } 064 065 public boolean isNativeLookAndFeel() { 066 return false; 067 } 068 069 public boolean isSupportedLookAndFeel() { 070 return true; 071 } 072 073 public UIDefaults getDefaults() { 074 if (myDefaults == null) { 075 initDefaults(); 076 } 077 return myDefaults; 078 } 079 080 private void initDefaults() { 081 myDefaults = new MyUIDefaults(); 082 Object[] mydefaults = { "TextFieldUI", 083 "org.jdesktop.swingx.plaf.ContextMenuAuxTextUI", 084 "EditorPaneUI", 085 "org.jdesktop.swingx.plaf.ContextMenuAuxTextUI", 086 "PasswordFieldUI", 087 "org.jdesktop.swingx.plaf.ContextMenuAuxTextUI", "TextAreaUI", 088 "org.jdesktop.swingx.plaf.ContextMenuAuxTextUI", "TextPaneUI", 089 "org.jdesktop.swingx.plaf.ContextMenuAuxTextUI", "ScrollBarUI", 090 "org.jdesktop.swingx.plaf.ContextMenuAuxScrollBarUI", }; 091 myDefaults.putDefaults(mydefaults); 092 } 093 094 /** 095 * UIDefaults without error msg. 096 * 097 */ 098 private static class MyUIDefaults extends UIDefaults { 099 100 /** 101 * Overridden to do nothing. 102 * There will be many errors because this is incomplete as 103 * of component types by design 104 * 105 */ 106 @Override 107 protected void getUIError(String msg) { 108 109 } 110 } 111 }