|
Mp3dings 20100427 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JMenuItem
javax.swing.JMenu
de.mospace.swing.LookAndFeelMenu
public class LookAndFeelMenu
A JMenu that lets you change the LookAndFeel of a window. The default
menutitle is LnF. Use setText() to change it.
An instance of this class will detect when the UIManager's lookAndFeel property changes and will select the corresponding menu item if it exists. No further action will be taken, in particular the LookAndFeelMenu will not update the application GUI. In general, once a client creates an instance of this class it should yield control over the LookAndFeel to the LookAndFeelMenu.
There should be no problem however to have several instances of this class.
LookAndFeelMenu(Preferences, Window, File, File, ClassLoader),
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JMenu |
|---|
JMenu.AccessibleJMenu, JMenu.WinListener |
| Nested classes/interfaces inherited from class javax.swing.JMenuItem |
|---|
JMenuItem.AccessibleJMenuItem |
| Nested classes/interfaces inherited from class javax.swing.AbstractButton |
|---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JMenu |
|---|
popupListener |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
LookAndFeelMenu(Preferences pref,
Window w)
Creates a new LookAndFeelMenu that remembers the selected LookAndFeel between program starts. |
|
LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties)
Creates a new LookAndFeelMenu that remembers the selected LookAndFeel between program starts and uses a fallback mechanism if the user does not have write access to the JRE directories. |
|
LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir)
Creates a new LookAndFeelMenu that remembers the selected LookAndFeel between program starts and uses a fallback mechanism if the user does not have write access to the JRE directories. |
|
LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir,
ClassLoader customCL)
Creates a new LookAndFeelMenu that remembers the selected LookAndFeel between program starts and uses a fallback mechanism if the user does not have write access to the JRE directories. |
|
LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir,
ClassLoaderProvider clp)
|
|
LookAndFeelMenu(Window w)
Creates a new LookAndFeelMenu that does not remember the selected LookAndFeel between program starts. |
|
| Method Summary | |
|---|---|
void |
setDialogParent(Component p)
|
static boolean |
setLookAndFeel(Preferences pref,
ClassLoader loader)
Tries to load a previously saved current LookAndFeel. |
protected boolean |
setLookAndFeel(String classname)
Constructs a new LookAndFeel object, calls UIManager.setLookAndFeel(LookAndFeel laf), and consumes all eventual exceptions. |
static boolean |
setLookAndFeel(String classname,
ClassLoader loader)
Tries to create an instance of the specified LookAndFeel class using the provided ClassLoader and calls UIManager.setLookAndFeel(LookAndFeel laf). |
protected void |
updateApplicationGui()
The default implementation updates the window provided to the constructor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface javax.swing.MenuElement |
|---|
processKeyEvent, processMouseEvent |
| Constructor Detail |
|---|
public LookAndFeelMenu(Window w)
Equivalent to
.
LookAndFeelMenu(null, w, null, null, null)
w - the window so set the look and feel of. May be null.
public LookAndFeelMenu(Preferences pref,
Window w)
Equivalent to
.
LookAndFeelMenu(pref, w, null, null, null)
pref - the preferences node to read from and write tow - the window so set the look and feel of, may be null
public LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties)
pref - the preferences node to read from and write tow - the window so set the look and feel of, may be nulllafProperties - a fallback properties file.LookAndFeelMenu(Preferences, Window, File, File, ClassLoader)
public LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir)
Note that if installdir is null the system class loader will
be used. Consider using
in this case.LookAndFeelMenu(Preferences pref, Window w, File lafProperties)
Equivalent to
LookAndFeelMenu(pref,
w,
lafProperties,
installdir,
createLibClassLoader(installdir))
pref - the preferences node to read from and write tow - the window so set the look and feel of, may be nulllafProperties - a fallback properties file. Can be null.installdir - a fallback installation directory.LookAndFeelMenu(Preferences, Window, File, File, ClassLoader)
public LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir,
ClassLoader customCL)
If possible LookAndFeel jar files will be installed to the first writable directory specified by the Java system property java.ext.dirs , and information about the installed LookAndFeels will be saved in lib/swing.properties .
If the user does not have write access to the extension directories the
jar files will be installed to installdir or the user will be
asked for a target directory if both installdir and
lafProperties are null. If only installdir
is null the parent directory of lafProperties will
be used as the installation target.
If lafProperties is not null information about the
installed LookAndFeels will be read from both
lib/swing.properties and lafProperties and saved to
lib/swing.properties if possible and lafProperties
otherwise.
In addition a custom class loader can be specified, which will be used
exclusively to instantiate LookAndFeel classes. A suitable classloader
can be created using a ClassLoaderProvider.
This is necessary whenever newly
installed jar files are not added to your classpath by some other
mechanism outside this class.
If you save the current LookAndFeel to Preferences your Application
should call setLookAndFeel(Preferences pref,
ClassLoader loader) before creating its GUI.
pref - the preference node from which to read and to which to save
the current LookAndFeel. If it is null the current
LookAndFeel will be forgotten when the JVM exits.w - the window whose LookAndFeel this LookAndFeelMenu controls. Can
be null.lafProperties - a fallback properties file. Can be null.installdir - a fallback installation directory. Can be null.customCL - Description of the Parameter
public LookAndFeelMenu(Preferences pref,
Window w,
File lafProperties,
File installdir,
ClassLoaderProvider clp)
| Method Detail |
|---|
public void setDialogParent(Component p)
protected boolean setLookAndFeel(String classname)
classname - the classname of the new LookAndFeel
UIManager.setLookAndFeel(LookAndFeel laf)
public static boolean setLookAndFeel(String classname,
ClassLoader loader)
This method should be used from outside this class and its subclasses only when no GUI components and in particular no instances of this class have been created.
classname - the classname of the new LookAndFeelloader - the classloader that will be used to create an instance of
the LookAndFeel class. If loader is null the system class
loader will be used instead.
- Returns:
- false if an exception occurred true otherwise
- See Also:
UIManager.setLookAndFeel(LookAndFeel laf)
public static boolean setLookAndFeel(Preferences pref,
ClassLoader loader)
UIManager.getSystemLookAndFeelClassName() is used as a default.
Consumes all eventual exceptions.This method should be used from outside this class and its subclasses only when no GUI components and in particular no instances of this class have been created.
pref - the Preferences node to load the LookAndFeel fromloader - the classloader that will be used to create an instance of
the LookAndFeel class. If loader is null the system class
loader will be used instead.
- Returns:
- false if an exception occurred true otherwise
- See Also:
UIManager.setLookAndFeel(LookAndFeel laf)protected void updateApplicationGui()
|
Mp3dings 20100427 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||