UI components are now cached

This commit is contained in:
nathan 2017-07-16 12:22:23 +02:00
parent 08b86cf16f
commit e1a191e155

View File

@ -56,7 +56,6 @@ class LinuxSwingUI implements SwingUIFactory {
public static class Metal_MenuItemBorder extends MetalBorders.MenuItemBorder {
private final int verticalPadding;
public
Metal_MenuItemBorder(int 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)
*
@ -80,7 +83,8 @@ class LinuxSwingUI implements SwingUIFactory {
@Override
public
PopupMenuUI getMenuUI(final JPopupMenu jPopupMenu, final Menu entry) {
return new DefaultPopupMenuUI(jPopupMenu) {
if (popupMenuUI == null) {
popupMenuUI = new DefaultPopupMenuUI(jPopupMenu) {
@Override
public
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
*
@ -106,7 +113,8 @@ class LinuxSwingUI implements SwingUIFactory {
@Override
public
MenuItemUI getItemUI(final JMenuItem jMenuItem, final Entry entry) {
return new DefaultMenuItemUI(jMenuItem) {
if (menuItemUI == null) {
menuItemUI = new DefaultMenuItemUI(jMenuItem) {
@Override
public
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
*
@ -131,9 +142,12 @@ class LinuxSwingUI implements SwingUIFactory {
@Override
public
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