
junit.extensions.jfcunit.finder.JPopupMenuFinder Maven / Gradle / Ivy
The newest version!
package junit.extensions.jfcunit.finder;
import java.awt.Component;
import javax.swing.JPopupMenu;
/**
*
* Title: Find a popup menu given the invoker.
*
*
* Description: Locate the popup menu associated with the invoker.
*
*
* Copyright: Copyright (c) 2003
*
*
* Company: JFCUnit OpenSource Project
*
*
* @author Kevin Wilson
* @version 1.0
*/
public class JPopupMenuFinder extends Finder
{
/**
* The Invoker of the Popup Menu.
*/
private Component m_invoker;
/**
* Constructor.
*
* @param invoker
* Component which is used to determine which menu to return.
*/
public JPopupMenuFinder(final Component invoker)
{
setInvoker(invoker);
setWait(2);
}
/**
* Set the invoker to be matched.
*
* @param invoker
* Component invoker to be matched.
*/
public final void setInvoker(final Component invoker)
{
this.m_invoker = invoker;
}
/**
* Get the invoker to be matched.
*
* @return Component invoker to be matched.
*/
public final Component getInvoker()
{
return this.m_invoker;
}
/**
* For JPopupMenu components validate return all Components with the
* invoker.
*
* @param comp
* Component to be tested.
* @return boolean true if the invokers of the JPopupMenu matches the
* invoker passed in the constructor.
*/
@Override
public boolean testComponent(final Component comp)
{
if (isValidForProcessing(comp, JPopupMenu.class))
{
return this.m_invoker.equals(((JPopupMenu) comp).getInvoker());
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy