All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alee.laf.menu.AbstractMenuItemPainter Maven / Gradle / Ivy

The newest version!
package com.alee.laf.menu;

import com.alee.laf.button.AbstractButtonPainter;
import com.alee.painter.decoration.IDecoration;

import javax.swing.*;
import javax.swing.plaf.MenuItemUI;

/**
 * Abstract painter for {@link JMenuItem} implementations.
 *
 * @param  component type
 * @param  component UI type
 * @param  decoration type
 * @author Alexandr Zernov
 * @author Mikle Garin
 */

public abstract class AbstractMenuItemPainter>
        extends AbstractButtonPainter implements IAbstractMenuItemPainter
{
    /**
     * Menu item change listener.
     */
    protected transient MenuItemChangeListener menuItemChangeListener;

    @Override
    protected void installPropertiesAndListeners ()
    {
        super.installPropertiesAndListeners ();
        installMenuItemChangeListener ();
    }

    @Override
    protected void uninstallPropertiesAndListeners ()
    {
        uninstallMenuItemChangeListener ();
        super.uninstallPropertiesAndListeners ();
    }

    @Override
    protected boolean isSelected ()
    {
        return component.isEnabled () && ( component.getModel ().isArmed () || component.getModel ().isSelected () );
    }

    /**
     * Installs {@link MenuItemChangeListener} into {@link JMenuItem}.
     */
    protected void installMenuItemChangeListener ()
    {
        menuItemChangeListener = MenuItemChangeListener.install ( component );
    }

    /**
     * Uninstalls {@link MenuItemChangeListener} from {@link JMenuItem}.
     */
    protected void uninstallMenuItemChangeListener ()
    {
        menuItemChangeListener = MenuItemChangeListener.uninstall ( menuItemChangeListener, component );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy