/*
* 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.
*/
/**
* BasicMenuItem implementation
*
* @author Georges Saab
* @author David Karlton
* @author Arnaud Weber
* @author Fredrik Lagerblad
*/
{
/**
* Accelerator delimiter string, such as {@code '+'} in {@code 'Ctrl+C'}.
* @since 1.7
*/
protected int defaultTextIconGap;
/**
* <code>PropertyChangeListener</code> returned from
* <code>createPropertyChangeListener</code>. You should not
* need to access this field, rather if you want to customize the
* <code>PropertyChangeListener</code> override
* <code>createPropertyChangeListener</code>.
*
* @since 1.6
* @see #createPropertyChangeListener
*/
// BasicMenuUI also uses this.
protected boolean oldBorderPainted;
/* diagnostic aids -- should be false for production builds. */
// NOTE: BasicMenuUI also calls into this method.
}
return new BasicMenuItemUI();
}
}
protected void installDefaults() {
// use default if missing so that BasicMenuItemUI can be used in other
// LAFs like Nimbus
if (acceleratorFont == null) {
}
}
else {
}
}
prefix + ".background",
prefix + ".foreground",
prefix + ".font");
// MenuItem specific defaults
if (selectionBackground == null ||
selectionBackground instanceof UIResource) {
}
if (selectionForeground == null ||
selectionForeground instanceof UIResource) {
}
if (disabledForeground == null ||
disabledForeground instanceof UIResource) {
}
if (acceleratorForeground == null ||
acceleratorForeground instanceof UIResource) {
}
if (acceleratorSelectionForeground == null ||
acceleratorSelectionForeground instanceof UIResource) {
}
// Get accelerator delimiter
// Icons
arrowIcon instanceof UIResource) {
}
checkIcon instanceof UIResource) {
//In case of column layout, .checkIconFactory is defined for this UI,
//the icon is compatible with it and useCheckAndArrow() is true,
//then the icon is handled by the checkIcon.
if (isColumnLayout) {
+ ".checkIconFactory");
if (iconFactory != null
}
}
}
}
/**
* @since 1.3
*/
}
return "MenuItem";
}
protected void installListeners() {
}
}
}
}
}
protected void installKeyboardActions() {
}
void installLazyActionMap() {
getPropertyPrefix() + ".actionMap");
}
}
protected void uninstallDefaults() {
if (arrowIcon instanceof UIResource)
if (checkIcon instanceof UIResource)
}
/**
* @since 1.3
*/
}
protected void uninstallListeners() {
if (mouseInputListener != null) {
}
if (menuDragMouseListener != null) {
}
if (menuKeyListener != null) {
}
if (propertyChangeListener != null) {
}
}
protected void uninstallKeyboardActions() {
}
return getHandler();
}
return getHandler();
}
return null;
}
/**
* Creates a <code>PropertyChangeListener</code> which will be added to
* the menu item.
* If this method returns null then it will not be added to the menu item.
*
* @return an instance of a <code>PropertyChangeListener</code> or null
* @since 1.6
*/
protected PropertyChangeListener
return getHandler();
}
}
return handler;
}
return new ComponentInputMapUIResource(menuItem);
}
return null;
}
void updateAcceleratorBinding() {
if (windowInputMap != null) {
}
if (accelerator != null) {
if (windowInputMap == null) {
}
}
}
if (v != null) {
d = getPreferredSize(c);
}
return d;
}
return getPreferredMenuItemSize(c,
}
if (v != null) {
d = getPreferredSize(c);
}
return d;
}
int defaultTextIconGap) {
// The method also determines the preferred width of the
// parent popup menu (through DefaultMenuLayout class).
// The menu width equals to the maximal width
// among child menu items.
// Menu item width will be a sum of the widest check icon, label,
// arrow icon and accelerator text among neighbor menu items.
// For the latest menu item we will know the maximal widths exactly.
// It will be the widest menu item and it will determine
// the width of the parent popup menu.
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// There is a conceptual problem: if user sets preferred size manually
// for a menu item, this method won't be called for it
// (see JComponent.getPreferredSize()),
// maximal widths won't be calculated, other menu items won't be able
// to take them into account and will be layouted in such a way,
// as there is no the item with manual preferred size.
// But after the first paint() method call, all maximal widths
// will be correctly calculated and layout of some menu items
// can be changed. For example, it can cause a shift of
// the icon and text when user points a menu item by mouse.
// Calculate the result width
// Take into account mimimal text offset.
if ((!lh.isTopLevelMenu())
}
// Calculate the result height
// Take into account menu item insets
}
// if the width is even, bump it up one. This is critical
// for the focus dash line to draw properly
}
// if the height is even, bump it up one. This is critical
// for the text to center properly
}
return result;
}
/**
* We draw the background in paintMenuItem()
* so override update (which fills the background of opaque
* components by default) to just call paint().
*
*/
paint(g, c);
}
}
int defaultTextIconGap) {
// Save original graphics font and color
// Restore original graphics font and color
}
// Use default icon
}
} else {
}
lr.getIconRect().y);
}
}
}
&& model.isSelected())) {
g.setColor(foreground);
} else {
}
if (lh.useCheckAndArrow()) {
}
}
}
// *** paint the accText disabled
if (disabledForeground != null) {
} else {
}
} else {
// *** paint the accText normally
&& model.isSelected())) {
} else {
}
}
}
}
// Text is HTML
} else {
// Text isn't HTML
}
}
}
Color foreground) {
&& model.isSelected())) {
g.setColor(foreground);
}
if (lh.useCheckAndArrow()) {
}
}
}
}
}
/**
* Draws the background of the menu item.
*
* @param g the paint graphics
* @param menuItem menu item to be painted
* @param bgColor selection background color
* @since 1.4
*/
} else {
}
}
model.isSelected())) {
}
}
/**
* Renders the text of the current menu item.
* <p>
* @param g graphics context
* @param menuItem menu item to render
* @param textRect bounding rectangle for rendering the text
* @param text string to render
* @since 1.4
*/
// *** paint the text disabled
} else {
}
} else {
// *** paint the text normally
}
}
}
if (i == 0)
return new MenuElement[0];
// The parent popup menu is the last so far
} else {
// A sibling menuitem is the current selection
//
// This probably needs to handle 'exit submenu into
// a menu item. Search backwards along the current
// selection until you find the parent popup menu,
// then copy up to that and add yourself...
int j;
break;
}
/*
System.out.println("Sibling condition -- ");
System.out.println("Old array : ");
printMenuElementArray(oldPath, false);
System.out.println("New array : ");
printMenuElementArray(newPath, false);
*/
}
return newPath;
}
int i, j;
for (int k=0; k<=i; k++)
else
}
if (dumpStack == true)
}
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().mouseClicked(e);
}
getHandler().mousePressed(e);
}
getHandler().mouseReleased(e);
}
getHandler().mouseEntered(e);
}
getHandler().mouseExited(e);
}
getHandler().mouseDragged(e);
}
getHandler().mouseMoved(e);
}
}
super(key);
}
}
}
/**
* Call this method when a menu item is to be activated.
* This method handles some of the details of menu item activation
* such as clearing the selected path and messaging the
* JMenuItem's doClick() method.
*
* @param msm A MenuSelectionManager. The visual feedback and
* internal bookkeeping tasks are delegated to
* this MenuSelectionManager. If <code>null</code> is
* passed as this argument, the
* <code>MenuSelectionManager.defaultManager</code> is
* used.
* @see MenuSelectionManager
* @see JMenuItem#doClick(int)
* @since 1.4
*/
// Auditory cue
if (! isInternalFrameSystemMenu()) {
".commandSound");
}
// Visual feedback
}
}
/**
* This is to see if the menu item in question is part of the
* system menu on an internal frame.
* The Strings that are being checked can be found in
*
* @since 1.4
*/
private boolean isInternalFrameSystemMenu() {
if ((actionCommand == "Close") ||
(actionCommand == "Minimize") ||
(actionCommand == "Restore") ||
(actionCommand == "Maximize")) {
return true;
} else {
return false;
}
}
// BasicMenuUI subclasses this.
//
// MouseInputListener
//
}
return;
}
} else {
}
}
int modifiers = e.getModifiers();
} else {
}
}
int modifiers = e.getModifiers();
} else {
int i,c;
}
}
}
}
}
//
// MenuDragListener
//
}
}
return;
}
} else {
}
}
//
// PropertyChangeListener
//
name == "accelerator") {
"foreground" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.
} else if (name == "iconTextGap") {
}
}
}
}