Class JPopupMenuHelper
- java.lang.Object
- 
- com.inductiveautomation.ignition.client.util.gui.popup.JPopupMenuHelper
 
- 
- All Implemented Interfaces:
- java.awt.event.MouseListener,- java.util.EventListener,- javax.swing.event.PopupMenuListener
 
 public class JPopupMenuHelper extends java.lang.Object implements java.awt.event.MouseListener, javax.swing.event.PopupMenuListenerThis class contains the correct logic for a component that wants to pop up a popup menu. You'd think this was unnecessary, but it's tricky to do correctly because if you pop up the popup on mouse press, it'll be wrong in the case when the press should "toggle" the popup's visibility. This is because The press will first hide the popup automatically, and then the press would show the popup again.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.awt.Componentcomponentprotected longlastHiddenprotected PopupLocationlocationprotected booleanmemoizePopupprotected javax.swing.JPopupMenupopupprotected java.util.function.Supplier<javax.swing.JPopupMenu>popupMakerprotected longthresholdprotected PopupTriggertrigger
 - 
Constructor SummaryConstructors Constructor Description JPopupMenuHelper(java.awt.Component component, java.util.function.Supplier<javax.swing.JPopupMenu> popupMaker)Alternate constructor allows for lazy popup instantiationJPopupMenuHelper(java.awt.Component component, javax.swing.JPopupMenu popup)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.PointadjustPopupLocationToFitScreen(int xPosition, int yPosition)Moves the popup location so that the menu does not overlap the task bar.protected java.awt.PointadjustPopupLocationToFitWindow(int xPosition, int yPosition)voidbind()static voidbind(java.awt.Component component, javax.swing.JPopupMenu popup)Creates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it.voiddoShowPopup(java.awt.event.MouseEvent e)java.awt.ComponentgetComponent()PopupLocationgetLocation()javax.swing.JPopupMenugetPopup()longgetThreshold()PopupTriggergetTrigger()booleanisMemoizePopup()voidmouseClicked(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidpopupMenuCanceled(javax.swing.event.PopupMenuEvent e)voidpopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)voidpopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e)voidsetComponent(java.awt.Component component)voidsetLocation(PopupLocation location)voidsetMemoizePopup(boolean memoizePopup)Controls whether the menu supplier is only called once (the default) or every time the popup is shown.voidsetPopup(javax.swing.JPopupMenu popup)voidsetThreshold(long threshold)voidsetTrigger(PopupTrigger trigger)voidunbind()
 
- 
- 
- 
Field Detail- 
componentprotected java.awt.Component component 
 - 
popupprotected javax.swing.JPopupMenu popup 
 - 
popupMakerprotected java.util.function.Supplier<javax.swing.JPopupMenu> popupMaker 
 - 
triggerprotected PopupTrigger trigger 
 - 
locationprotected PopupLocation location 
 - 
memoizePopupprotected boolean memoizePopup 
 - 
lastHiddenprotected long lastHidden 
 - 
thresholdprotected long threshold 
 
- 
 - 
Constructor Detail- 
JPopupMenuHelperpublic JPopupMenuHelper(java.awt.Component component, javax.swing.JPopupMenu popup)
 - 
JPopupMenuHelperpublic JPopupMenuHelper(java.awt.Component component, java.util.function.Supplier<javax.swing.JPopupMenu> popupMaker)Alternate constructor allows for lazy popup instantiation
 
- 
 - 
Method Detail- 
bindpublic void bind() 
 - 
unbindpublic void unbind() 
 - 
bindpublic static void bind(java.awt.Component component, javax.swing.JPopupMenu popup)Creates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it.
 - 
setTriggerpublic void setTrigger(PopupTrigger trigger) 
 - 
getTriggerpublic PopupTrigger getTrigger() 
 - 
setLocationpublic void setLocation(PopupLocation location) 
 - 
getLocationpublic PopupLocation getLocation() 
 - 
getThresholdpublic long getThreshold() 
 - 
setThresholdpublic void setThreshold(long threshold) 
 - 
setComponentpublic void setComponent(java.awt.Component component) 
 - 
getComponentpublic java.awt.Component getComponent() 
 - 
setPopuppublic void setPopup(javax.swing.JPopupMenu popup) 
 - 
getPopuppublic javax.swing.JPopupMenu getPopup() 
 - 
setMemoizePopuppublic void setMemoizePopup(boolean memoizePopup) Controls whether the menu supplier is only called once (the default) or every time the popup is shown. This setting is only used if the popup menu helper was created with a menu supplier.
 - 
isMemoizePopuppublic boolean isMemoizePopup() 
 - 
popupMenuWillBecomeVisiblepublic void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e) - Specified by:
- popupMenuWillBecomeVisiblein interface- javax.swing.event.PopupMenuListener
 
 - 
popupMenuWillBecomeInvisiblepublic void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e) - Specified by:
- popupMenuWillBecomeInvisiblein interface- javax.swing.event.PopupMenuListener
 
 - 
popupMenuCanceledpublic void popupMenuCanceled(javax.swing.event.PopupMenuEvent e) - Specified by:
- popupMenuCanceledin interface- javax.swing.event.PopupMenuListener
 
 - 
mouseClickedpublic void mouseClicked(java.awt.event.MouseEvent e) - Specified by:
- mouseClickedin interface- java.awt.event.MouseListener
 
 - 
doShowPopuppublic void doShowPopup(java.awt.event.MouseEvent e) 
 - 
mousePressedpublic void mousePressed(java.awt.event.MouseEvent e) - Specified by:
- mousePressedin interface- java.awt.event.MouseListener
 
 - 
mouseReleasedpublic void mouseReleased(java.awt.event.MouseEvent e) - Specified by:
- mouseReleasedin interface- java.awt.event.MouseListener
 
 - 
mouseEnteredpublic void mouseEntered(java.awt.event.MouseEvent e) - Specified by:
- mouseEnteredin interface- java.awt.event.MouseListener
 
 - 
mouseExitedpublic void mouseExited(java.awt.event.MouseEvent e) - Specified by:
- mouseExitedin interface- java.awt.event.MouseListener
 
 - 
adjustPopupLocationToFitScreenprotected java.awt.Point adjustPopupLocationToFitScreen(int xPosition, int yPosition)Moves the popup location so that the menu does not overlap the task bar. This is taken from JPopupMenu.java. The JPopupMenu version has a condition that can allow the screen insets to not be considered in the adjustment. This was taken in full in order to perform the same function while forcing the insets to be part of the adjustment.
 - 
adjustPopupLocationToFitWindowprotected java.awt.Point adjustPopupLocationToFitWindow(int xPosition, int yPosition)
 
- 
 
-