< prev index next >
src/java.desktop/share/classes/javax/swing/JMenu.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -1200,11 +1200,11 @@
@BeanProperty(bound = false)
public MenuElement[] getSubElements() {
if(popupMenu == null)
return new MenuElement[0];
else {
- MenuElement result[] = new MenuElement[1];
+ MenuElement[] result = new MenuElement[1];
result[0] = popupMenu;
return result;
}
}
@@ -1283,11 +1283,11 @@
* <code>AbstractButton.doClick</code> in order to make the menu pop up.
* @param pressTime indicates the number of milliseconds the
* button was pressed for
*/
public void doClick(int pressTime) {
- MenuElement me[] = buildMenuElementArray(this);
+ MenuElement[] me = buildMenuElementArray(this);
MenuSelectionManager.defaultManager().setSelectedPath(me);
}
/*
* Build an array of menu elements - from <code>PopupMenu</code> to
@@ -1317,11 +1317,11 @@
break;
} else {
break;
}
}
- MenuElement me[] = new MenuElement[elements.size()];
+ MenuElement[] me = new MenuElement[elements.size()];
elements.copyInto(me);
return me;
}
@@ -1469,11 +1469,11 @@
* Returns 1 if a sub-menu is currently selected in this menu.
*
* @return 1 if a menu is currently selected, else 0
*/
public int getAccessibleSelectionCount() {
- MenuElement me[] =
+ MenuElement[] me =
MenuSelectionManager.defaultManager().getSelectedPath();
if (me != null) {
for (int i = 0; i < me.length; i++) {
if (me[i] == JMenu.this) { // this menu is selected
if (i+1 < me.length) {
@@ -1494,11 +1494,11 @@
public Accessible getAccessibleSelection(int i) {
// if i is a sub-menu & popped, return it
if (i < 0 || i >= getItemCount()) {
return null;
}
- MenuElement me[] =
+ MenuElement[] me =
MenuSelectionManager.defaultManager().getSelectedPath();
if (me != null) {
for (int j = 0; j < me.length; j++) {
if (me[j] == JMenu.this) { // this menu is selected
// so find the next JMenuItem in the MenuElement
@@ -1522,11 +1522,11 @@
* object.
* @see AccessibleContext#getAccessibleChild
*/
public boolean isAccessibleChildSelected(int i) {
// if i is a sub-menu and is pop-ed up, return true, else false
- MenuElement me[] =
+ MenuElement[] me =
MenuSelectionManager.defaultManager().getSelectedPath();
if (me != null) {
JMenuItem mi = JMenu.this.getItem(i);
for (int j = 0; j < me.length; j++) {
if (me[j] == mi) {
@@ -1554,11 +1554,11 @@
return;
}
JMenuItem mi = getItem(i);
if (mi != null) {
if (mi instanceof JMenu) {
- MenuElement me[] = buildMenuElementArray((JMenu) mi);
+ MenuElement[] me = buildMenuElementArray((JMenu) mi);
MenuSelectionManager.defaultManager().setSelectedPath(me);
} else {
MenuSelectionManager.defaultManager().setSelectedPath(null);
}
}
@@ -1576,13 +1576,13 @@
return;
}
JMenuItem mi = getItem(i);
if (mi != null && mi instanceof JMenu) {
if (mi.isSelected()) {
- MenuElement old[] =
+ MenuElement[] old =
MenuSelectionManager.defaultManager().getSelectedPath();
- MenuElement me[] = new MenuElement[old.length-2];
+ MenuElement[] me = new MenuElement[old.length-2];
for (int j = 0; j < old.length -2; j++) {
me[j] = old[j];
}
MenuSelectionManager.defaultManager().setSelectedPath(me);
}
@@ -1594,16 +1594,16 @@
* object is selected. This will close any open sub-menu.
*/
public void clearAccessibleSelection() {
// if this menu is selected, reset selection to only go
// to this menu; else do nothing
- MenuElement old[] =
+ MenuElement[] old =
MenuSelectionManager.defaultManager().getSelectedPath();
if (old != null) {
for (int j = 0; j < old.length; j++) {
if (old[j] == JMenu.this) { // menu is in the selection!
- MenuElement me[] = new MenuElement[j+1];
+ MenuElement[] me = new MenuElement[j+1];
System.arraycopy(old, 0, me, 0, j);
me[j] = JMenu.this.getPopupMenu();
MenuSelectionManager.defaultManager().setSelectedPath(me);
}
}
< prev index next >