forked from dorkbox/SystemTray
UI components are now cached
This commit is contained in:
parent
08b86cf16f
commit
e1a191e155
@ -56,7 +56,6 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
public static class Metal_MenuItemBorder extends MetalBorders.MenuItemBorder {
|
public static class Metal_MenuItemBorder extends MetalBorders.MenuItemBorder {
|
||||||
private final int verticalPadding;
|
private final int verticalPadding;
|
||||||
|
|
||||||
public
|
|
||||||
Metal_MenuItemBorder(int verticalPadding) {
|
Metal_MenuItemBorder(int verticalPadding) {
|
||||||
this.verticalPadding = verticalPadding;
|
this.verticalPadding = verticalPadding;
|
||||||
}
|
}
|
||||||
@ -69,6 +68,10 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PopupMenuUI popupMenuUI = null;
|
||||||
|
private static MenuItemUI menuItemUI = null;
|
||||||
|
private static SeparatorUI separatorUI = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows one to specify the Look & Feel of the menus (The main SystemTray and sub-menus)
|
* Allows one to specify the Look & Feel of the menus (The main SystemTray and sub-menus)
|
||||||
*
|
*
|
||||||
@ -80,7 +83,8 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
PopupMenuUI getMenuUI(final JPopupMenu jPopupMenu, final Menu entry) {
|
PopupMenuUI getMenuUI(final JPopupMenu jPopupMenu, final Menu entry) {
|
||||||
return new DefaultPopupMenuUI(jPopupMenu) {
|
if (popupMenuUI == null) {
|
||||||
|
popupMenuUI = new DefaultPopupMenuUI(jPopupMenu) {
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void installUI(final JComponent c) {
|
void installUI(final JComponent c) {
|
||||||
@ -95,6 +99,9 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return popupMenuUI;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows one to specify the Look & Feel of a menu entry
|
* Allows one to specify the Look & Feel of a menu entry
|
||||||
*
|
*
|
||||||
@ -106,7 +113,8 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
MenuItemUI getItemUI(final JMenuItem jMenuItem, final Entry entry) {
|
MenuItemUI getItemUI(final JMenuItem jMenuItem, final Entry entry) {
|
||||||
return new DefaultMenuItemUI(jMenuItem) {
|
if (menuItemUI == null) {
|
||||||
|
menuItemUI = new DefaultMenuItemUI(jMenuItem) {
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void installUI(final JComponent c) {
|
void installUI(final JComponent c) {
|
||||||
@ -121,6 +129,9 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return menuItemUI;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows one to specify the Look & Feel of a menu separator entry
|
* Allows one to specify the Look & Feel of a menu separator entry
|
||||||
*
|
*
|
||||||
@ -131,9 +142,12 @@ class LinuxSwingUI implements SwingUIFactory {
|
|||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
SeparatorUI getSeparatorUI(final JSeparator jSeparator) {
|
SeparatorUI getSeparatorUI(final JSeparator jSeparator) {
|
||||||
return new DefaultSeparatorUI(jSeparator);
|
if (separatorUI == null) {
|
||||||
|
separatorUI = new DefaultSeparatorUI(jSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return separatorUI;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This saves a vector CheckMark to a correctly sized PNG file. The checkmark image will ALWAYS be centered in the targetImageSize
|
* This saves a vector CheckMark to a correctly sized PNG file. The checkmark image will ALWAYS be centered in the targetImageSize
|
||||||
|
Loading…
Reference in New Issue
Block a user