/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A MenuSelectionManager owns the selection in menu hierarchy.
*
* @author Arnaud Weber
*/
public class MenuSelectionManager {
/* diagnostic aids -- should be false for production builds. */
new StringBuilder("javax.swing.MenuSelectionManager");
/**
* Returns the default menu selection manager.
*
* @return a MenuSelectionManager object
*/
synchronized (MENU_SELECTION_MANAGER_KEY) {
msm = new MenuSelectionManager();
}
return msm;
}
}
/**
* Only one ChangeEvent is needed per button model instance since the
* event's only state is the source property. The source of events
* generated is always "this".
*/
/**
* Changes the selection in the menu hierarchy. The elements
* in the array are sorted in order from the root menu
* element to the currently selected menu element.
* <p>
* Note that this method is public but is used by the look and
* feel engine and should not be called by client applications.
*
* @param path an array of <code>MenuElement</code> objects specifying
* the selected path
*/
int i,c;
int firstDifference = 0;
}
if (DEBUG) {
}
else
break;
}
me.menuSelectionChanged(false);
}
path[i].menuSelectionChanged(true);
}
}
}
/**
* Returns the path to the currently selected menu item
*
* @return an array of MenuElement objects representing the selected path
*/
int i,c;
return res;
}
/**
* Tell the menu selection to close and unselect all the menu components. Call this method
* when a choice has been made
*/
public void clearSelectedPath() {
}
}
/**
* Adds a ChangeListener to the button.
*
* @param l the listener to add
*/
}
/**
* Removes a ChangeListener from the button.
*
* @param l the listener to remove
*/
}
/**
* Returns an array of all the <code>ChangeListener</code>s added
* to this MenuSelectionManager with addChangeListener().
*
* @return all of the <code>ChangeListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
* is created lazily.
*
* @see EventListenerList
*/
protected void fireStateChanged() {
// Guaranteed to return a non-null array
// Process the listeners last to first, notifying
// those that are interested in this event
if (listeners[i]==ChangeListener.class) {
// Lazily create the event:
if (changeEvent == null)
changeEvent = new ChangeEvent(this);
}
}
}
/**
* When a MenuElement receives an event from a MouseListener, it should never process the event
* directly. Instead all MenuElements should call this method with the event.
*
* @param event a MouseEvent object
*/
Point p;
int i,c,j,d;
MenuElement path[];
int selectionSize;
// This can happen if a mouseReleased removes the
// containing component -- bug 4146684
return;
}
return;
}
}
screenX = p.x;
screenY = p.y;
boolean success = false;
if (subElements[j] == null)
continue;
continue;
if(mc instanceof JComponent) {
} else {
}
p.x = screenX;
p.y = screenY;
/** Send the event to visible menu element if menu element currently in
* the selected path or contains the event location
*/
if(
int k;
for(k=0;k<=i;k++)
}
path[i+1] &&
path[i+1])) {
event.getModifiers(), p.x, p.y,
event.getModifiers(), p.x, p.y,
}
event.getModifiers(), p.x, p.y,
success = true;
}
}
}
}
printMenuElementArray(path, false);
}
int i, j;
for (int k=0; k<=i; k++)
} else if(me instanceof JPopupMenu) {
} else {
}
}
if (dumpStack == true)
}
/**
* Returns the component in the currently selected path
* which contains sourcePoint.
*
* @param source The component in whose coordinate space sourcePoint
* is given
* @param sourcePoint The point which is being tested
* @return The component in the currently selected path which
* contains sourcePoint (relative to the source component's
* coordinate space. If sourcePoint is not inside a component
* on the currently selected path, null is returned.
*/
Point p = sourcePoint;
int i,c,j,d;
int selectionSize;
screenX = p.x;
screenY = p.y;
if (subElements[j] == null)
continue;
continue;
if(mc instanceof JComponent) {
} else {
}
p.x = screenX;
p.y = screenY;
/** Return the deepest component on the selection
* path in whose bounds the event's point occurs
*/
return mc;
}
}
}
return null;
}
/**
* When a MenuElement receives an event from a KeyListener, it should never process the event
* directly. Instead all MenuElements should call this method with the event.
*
* @param e a KeyEvent object
*/
MenuElement[] path;
if (selSize < 1) {
return;
}
continue;
}
}
if (e.isConsumed()) {
return;
}
}
}
// finally dispatch event to the first component in path
if (e.isConsumed()) {
return;
}
}
/**
* Return true if c is part of the currently used menu
*/
return isComponentPartOfCurrentMenu(me,c);
} else
return false;
}
int i,d;
return false;
if(root.getComponent() == c)
return true;
else {
if(isComponentPartOfCurrentMenu(children[i],c))
return true;
}
}
return false;
}
}