com.alee.laf.menu
Class AdaptivePopupMenuPainter<E extends javax.swing.JPopupMenu>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.extended.painter.AdaptivePainter<E>
          extended by com.alee.laf.menu.AdaptivePopupMenuPainter<E>
All Implemented Interfaces:
Painter<E>, SpecificPainter, PopupMenuPainter<E>

public class AdaptivePopupMenuPainter<E extends javax.swing.JPopupMenu>
extends AdaptivePainter<E>
implements PopupMenuPainter<E>

Simple PopupMenuPainter adapter class. It is used to install simple non-specific painters into WebPopupMenuUI.

Author:
Mikle Garin

Field Summary
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
AdaptivePopupMenuPainter(Painter painter)
          Constructs new AdaptiveLabelPainter for the specified painter.
 
Method Summary
 java.awt.Point preparePopupMenu(E popupMenu, java.awt.Component invoker, int x, int y)
          Prepares popup menu to be displayed.
 void setFixLocation(boolean fix)
          Sets whether should fix initial popup menu location or not.
 void setMenuSpacing(int spacing)
          Sets spacing between popup menus.
 void setPopupMenuType(PopupMenuType type)
          Sets popup menu type.
 void setPopupMenuWay(PopupMenuWay way)
          Sets preferred popup menu display way.
 void setTransparent(boolean transparent)
          Sets whether popup menu is transparent or not.
 
Methods inherited from class com.alee.extended.painter.AdaptivePainter
addPainterListener, getMargin, getPainter, getPreferredSize, install, isOpaque, paint, removePainterListener, uninstall
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
p, repaint, repaint, repaint, revalidate, setMargin, setMargin, setMargin, setOpaque, setPreferredSize, updateAll, updateOpacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.extended.painter.Painter
addPainterListener, getMargin, getPreferredSize, install, isOpaque, paint, removePainterListener, uninstall
 

Constructor Detail

AdaptivePopupMenuPainter

public AdaptivePopupMenuPainter(Painter painter)
Constructs new AdaptiveLabelPainter for the specified painter.

Parameters:
painter - painter to adapt
Method Detail

setTransparent

public void setTransparent(boolean transparent)
Sets whether popup menu is transparent or not. This mark is updated only once per component as it is initialized on UI initialization only.

Specified by:
setTransparent in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
transparent - whether popup menu is transparent or not

setMenuSpacing

public void setMenuSpacing(int spacing)
Sets spacing between popup menus.

Specified by:
setMenuSpacing in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
spacing - spacing between popup menus

setFixLocation

public void setFixLocation(boolean fix)
Sets whether should fix initial popup menu location or not. If set to true popup menu will try to use best possible location to show up.

This is set to true by default to place menubar and menu popups correctly. You might want to set this to false for some specific popup menu, but not all of them at once.

Specified by:
setFixLocation in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
fix - whether should fix initial popup menu location or not

setPopupMenuWay

public void setPopupMenuWay(PopupMenuWay way)
Sets preferred popup menu display way. This value is updated right before preparePopupMenu method call.

Specified by:
setPopupMenuWay in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
way - preferred popup menu display way

setPopupMenuType

public void setPopupMenuType(PopupMenuType type)
Sets popup menu type. This value is updated right before popup menu window becomes visible. You can use it to draw different popup menu decoration for each popup menu type.

Specified by:
setPopupMenuType in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
type - popup menu type

preparePopupMenu

public java.awt.Point preparePopupMenu(E popupMenu,
                                       java.awt.Component invoker,
                                       int x,
                                       int y)
Prepares popup menu to be displayed.

Specified by:
preparePopupMenu in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
popupMenu - JPopupMenu to prepare for display
x - screen x location actual popup is to be shown at
y - screen y location actual popup is to be shown at
Returns:
modified popup display location