Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see .
*/
package com.alee.laf.menu;
import com.alee.painter.Paintable;
import com.alee.painter.Painter;
import com.alee.laf.WebLookAndFeel;
import com.alee.managers.hotkey.HotkeyData;
import com.alee.managers.language.LanguageManager;
import com.alee.managers.language.LanguageMethods;
import com.alee.managers.language.updaters.LanguageUpdater;
import com.alee.managers.log.Log;
import com.alee.managers.style.*;
import com.alee.managers.style.Skin;
import com.alee.managers.style.StyleListener;
import com.alee.managers.style.Skinnable;
import com.alee.utils.ReflectUtils;
import com.alee.utils.SwingUtils;
import com.alee.utils.swing.FontMethods;
import javax.swing.*;
import java.awt.*;
import java.util.Map;
/**
* This JMenuItem extension class provides a direct access to WebMenuItemUI methods.
*
* @author Mikle Garin
*/
public class WebMenuItem extends JMenuItem
implements Styleable, Skinnable, Paintable, MarginSupport, PaddingSupport, ShapeProvider, LanguageMethods, FontMethods
{
/**
* Constructs new menu item.
*/
public WebMenuItem ()
{
super ();
}
/**
* Constructs new menu item using the specified settings.
*
* @param icon menu item icon
*/
public WebMenuItem ( final Icon icon )
{
super ( icon );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
*/
public WebMenuItem ( final String text )
{
super ( text );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final String text, final KeyStroke accelerator )
{
super ( text );
setAccelerator ( accelerator );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final String text, final HotkeyData accelerator )
{
super ( text );
setAccelerator ( accelerator );
}
/**
* Constructs new menu item using the specified settings.
*
* @param a menu item action
*/
public WebMenuItem ( final Action a )
{
super ( a );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param icon menu item icon
*/
public WebMenuItem ( final String text, final Icon icon )
{
super ( text, icon );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param mnemonic menu item mnemonic
*/
public WebMenuItem ( final String text, final int mnemonic )
{
super ( text, mnemonic );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param icon menu item icon
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final String text, final Icon icon, final KeyStroke accelerator )
{
super ( text, icon );
setAccelerator ( accelerator );
}
/**
* Constructs new menu item using the specified settings.
*
* @param text menu item text
* @param icon menu item icon
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final String text, final Icon icon, final HotkeyData accelerator )
{
super ( text, icon );
setAccelerator ( accelerator );
}
/**
* Constructs new menu item.
*
* @param id style ID
*/
public WebMenuItem ( final StyleId id )
{
super ();
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param icon menu item icon
*/
public WebMenuItem ( final StyleId id, final Icon icon )
{
super ( icon );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
*/
public WebMenuItem ( final StyleId id, final String text )
{
super ( text );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final StyleId id, final String text, final KeyStroke accelerator )
{
super ( text );
setAccelerator ( accelerator );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final StyleId id, final String text, final HotkeyData accelerator )
{
super ( text );
setAccelerator ( accelerator );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param a menu item action
*/
public WebMenuItem ( final StyleId id, final Action a )
{
super ( a );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param icon menu item icon
*/
public WebMenuItem ( final StyleId id, final String text, final Icon icon )
{
super ( text, icon );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param mnemonic menu item mnemonic
*/
public WebMenuItem ( final StyleId id, final String text, final int mnemonic )
{
super ( text, mnemonic );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param icon menu item icon
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final StyleId id, final String text, final Icon icon, final KeyStroke accelerator )
{
super ( text, icon );
setAccelerator ( accelerator );
setStyleId ( id );
}
/**
* Constructs new menu item using the specified settings.
*
* @param id style ID
* @param text menu item text
* @param icon menu item icon
* @param accelerator menu item accelerator
*/
public WebMenuItem ( final StyleId id, final String text, final Icon icon, final HotkeyData accelerator )
{
super ( text, icon );
setAccelerator ( accelerator );
setStyleId ( id );
}
/**
* Sets the key combination which invokes the menu item's action listeners without navigating the menu hierarchy.
*
* @param hotkey hotkey data
*/
public void setAccelerator ( final HotkeyData hotkey )
{
SwingUtils.setAccelerator ( this, hotkey );
}
@Override
public StyleId getStyleId ()
{
return getWebUI ().getStyleId ();
}
@Override
public StyleId setStyleId ( final StyleId id )
{
return getWebUI ().setStyleId ( id );
}
@Override
public Skin getSkin ()
{
return StyleManager.getSkin ( this );
}
@Override
public Skin setSkin ( final Skin skin )
{
return StyleManager.setSkin ( this, skin );
}
@Override
public Skin setSkin ( final Skin skin, final boolean recursively )
{
return StyleManager.setSkin ( this, skin, recursively );
}
@Override
public Skin restoreSkin ()
{
return StyleManager.restoreSkin ( this );
}
@Override
public void addStyleListener ( final StyleListener listener )
{
StyleManager.addStyleListener ( this, listener );
}
@Override
public void removeStyleListener ( final StyleListener listener )
{
StyleManager.removeStyleListener ( this, listener );
}
@Override
public Map getCustomPainters ()
{
return StyleManager.getCustomPainters ( this );
}
@Override
public Painter getCustomPainter ()
{
return StyleManager.getCustomPainter ( this );
}
@Override
public Painter getCustomPainter ( final String id )
{
return StyleManager.getCustomPainter ( this, id );
}
@Override
public Painter setCustomPainter ( final Painter painter )
{
return StyleManager.setCustomPainter ( this, painter );
}
@Override
public Painter setCustomPainter ( final String id, final Painter painter )
{
return StyleManager.setCustomPainter ( this, id, painter );
}
@Override
public boolean restoreDefaultPainters ()
{
return StyleManager.restoreDefaultPainters ( this );
}
@Override
public Shape provideShape ()
{
return getWebUI ().provideShape ();
}
@Override
public Insets getMargin ()
{
return getWebUI ().getMargin ();
}
/**
* Sets new margin.
*
* @param margin new margin
*/
public void setMargin ( final int margin )
{
setMargin ( margin, margin, margin, margin );
}
/**
* Sets new margin.
*
* @param top new top margin
* @param left new left margin
* @param bottom new bottom margin
* @param right new right margin
*/
public void setMargin ( final int top, final int left, final int bottom, final int right )
{
setMargin ( new Insets ( top, left, bottom, right ) );
}
@Override
public void setMargin ( final Insets margin )
{
getWebUI ().setMargin ( margin );
}
@Override
public Insets getPadding ()
{
return getWebUI ().getPadding ();
}
/**
* Sets new padding.
*
* @param padding new padding
*/
public void setPadding ( final int padding )
{
setPadding ( padding, padding, padding, padding );
}
/**
* Sets new padding.
*
* @param top new top padding
* @param left new left padding
* @param bottom new bottom padding
* @param right new right padding
*/
public void setPadding ( final int top, final int left, final int bottom, final int right )
{
setPadding ( new Insets ( top, left, bottom, right ) );
}
@Override
public void setPadding ( final Insets padding )
{
getWebUI ().setPadding ( padding );
}
/**
* Returns Web-UI applied to this class.
*
* @return Web-UI applied to this class
*/
private WebMenuItemUI getWebUI ()
{
return ( WebMenuItemUI ) getUI ();
}
/**
* Installs a Web-UI into this component.
*/
@Override
public void updateUI ()
{
if ( getUI () == null || !( getUI () instanceof WebMenuItemUI ) )
{
try
{
setUI ( ( WebMenuItemUI ) ReflectUtils.createInstance ( WebLookAndFeel.menuItemUI ) );
}
catch ( final Throwable e )
{
Log.error ( this, e );
setUI ( new WebMenuItemUI () );
}
}
else
{
setUI ( getUI () );
}
}
@Override
public void setLanguage ( final String key, final Object... data )
{
LanguageManager.registerComponent ( this, key, data );
}
@Override
public void updateLanguage ( final Object... data )
{
LanguageManager.updateComponent ( this, data );
}
@Override
public void updateLanguage ( final String key, final Object... data )
{
LanguageManager.updateComponent ( this, key, data );
}
@Override
public void removeLanguage ()
{
LanguageManager.unregisterComponent ( this );
}
@Override
public boolean isLanguageSet ()
{
return LanguageManager.isRegisteredComponent ( this );
}
@Override
public void setLanguageUpdater ( final LanguageUpdater updater )
{
LanguageManager.registerLanguageUpdater ( this, updater );
}
@Override
public void removeLanguageUpdater ()
{
LanguageManager.unregisterLanguageUpdater ( this );
}
@Override
public WebMenuItem setPlainFont ()
{
return SwingUtils.setPlainFont ( this );
}
@Override
public WebMenuItem setPlainFont ( final boolean apply )
{
return SwingUtils.setPlainFont ( this, apply );
}
@Override
public boolean isPlainFont ()
{
return SwingUtils.isPlainFont ( this );
}
@Override
public WebMenuItem setBoldFont ()
{
return SwingUtils.setBoldFont ( this );
}
@Override
public WebMenuItem setBoldFont ( final boolean apply )
{
return SwingUtils.setBoldFont ( this, apply );
}
@Override
public boolean isBoldFont ()
{
return SwingUtils.isBoldFont ( this );
}
@Override
public WebMenuItem setItalicFont ()
{
return SwingUtils.setItalicFont ( this );
}
@Override
public WebMenuItem setItalicFont ( final boolean apply )
{
return SwingUtils.setItalicFont ( this, apply );
}
@Override
public boolean isItalicFont ()
{
return SwingUtils.isItalicFont ( this );
}
@Override
public WebMenuItem setFontStyle ( final boolean bold, final boolean italic )
{
return SwingUtils.setFontStyle ( this, bold, italic );
}
@Override
public WebMenuItem setFontStyle ( final int style )
{
return SwingUtils.setFontStyle ( this, style );
}
@Override
public WebMenuItem setFontSize ( final int fontSize )
{
return SwingUtils.setFontSize ( this, fontSize );
}
@Override
public WebMenuItem changeFontSize ( final int change )
{
return SwingUtils.changeFontSize ( this, change );
}
@Override
public int getFontSize ()
{
return SwingUtils.getFontSize ( this );
}
@Override
public WebMenuItem setFontSizeAndStyle ( final int fontSize, final boolean bold, final boolean italic )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, bold, italic );
}
@Override
public WebMenuItem setFontSizeAndStyle ( final int fontSize, final int style )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, style );
}
@Override
public WebMenuItem setFontName ( final String fontName )
{
return SwingUtils.setFontName ( this, fontName );
}
@Override
public String getFontName ()
{
return SwingUtils.getFontName ( this );
}
}