< prev index next >
src/share/classes/javax/swing/JMenu.java
Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov
*** 369,380 ****
* of the <code>JMenu</code>'s popup menu
*
* @since 1.3
*/
protected Point getPopupMenuOrigin() {
! int x = 0;
! int y = 0;
JPopupMenu pm = getPopupMenu();
// Figure out the sizes needed to caclulate the menu position
Dimension s = getSize();
Dimension pmSize = pm.getSize();
// For the first time the menu is popped up,
--- 369,380 ----
* of the <code>JMenu</code>'s popup menu
*
* @since 1.3
*/
protected Point getPopupMenuOrigin() {
! int x;
! int y;
JPopupMenu pm = getPopupMenu();
// Figure out the sizes needed to caclulate the menu position
Dimension s = getSize();
Dimension pmSize = pm.getSize();
// For the first time the menu is popped up,
*** 898,911 ****
* @return true if the menu is activated from the menu bar;
* false if the menu is activated from a menu item
* on another menu
*/
public boolean isTopLevelMenu() {
! if (getParent() instanceof JMenuBar)
! return true;
- return false;
}
/**
* Returns true if the specified component exists in the
* submenu hierarchy.
--- 898,909 ----
* @return true if the menu is activated from the menu bar;
* false if the menu is activated from a menu item
* on another menu
*/
public boolean isTopLevelMenu() {
! return getParent() instanceof JMenuBar;
}
/**
* Returns true if the specified component exists in the
* submenu hierarchy.
*** 1013,1023 ****
* @return all of the <code>MenuListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public MenuListener[] getMenuListeners() {
! return (MenuListener[])listenerList.getListeners(MenuListener.class);
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
--- 1011,1021 ----
* @return all of the <code>MenuListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public MenuListener[] getMenuListeners() {
! return listenerList.getListeners(MenuListener.class);
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
*** 1303,1313 ****
* the root <code>JMenuBar</code>.
* @param leaf the leaf node from which to start building up the array
* @return the array of menu items
*/
private MenuElement[] buildMenuElementArray(JMenu leaf) {
! Vector elements = new Vector();
Component current = leaf.getPopupMenu();
JPopupMenu pop;
JMenu menu;
JMenuBar bar;
--- 1301,1311 ----
* the root <code>JMenuBar</code>.
* @param leaf the leaf node from which to start building up the array
* @return the array of menu items
*/
private MenuElement[] buildMenuElementArray(JMenu leaf) {
! Vector<MenuElement> elements = new Vector<MenuElement>();
Component current = leaf.getPopupMenu();
JPopupMenu pop;
JMenu menu;
JMenuBar bar;
*** 1407,1418 ****
* @return the number of accessible children in the object.
*/
public int getAccessibleChildrenCount() {
Component[] children = getMenuComponents();
int count = 0;
! for (int j = 0; j < children.length; j++) {
! if (children[j] instanceof Accessible) {
count++;
}
}
return count;
}
--- 1405,1416 ----
* @return the number of accessible children in the object.
*/
public int getAccessibleChildrenCount() {
Component[] children = getMenuComponents();
int count = 0;
! for (Component child : children) {
! if (child instanceof Accessible) {
count++;
}
}
return count;
}
*** 1424,1445 ****
* @return the nth Accessible child of the object
*/
public Accessible getAccessibleChild(int i) {
Component[] children = getMenuComponents();
int count = 0;
! for (int j = 0; j < children.length; j++) {
! if (children[j] instanceof Accessible) {
if (count == i) {
! if (children[j] instanceof JComponent) {
// FIXME: [[[WDW - probably should set this when
// the component is added to the menu. I tried
// to do this in most cases, but the separators
// added by addSeparator are hard to get to.]]]
! AccessibleContext ac = ((Accessible) children[j]).getAccessibleContext();
ac.setAccessibleParent(JMenu.this);
}
! return (Accessible) children[j];
} else {
count++;
}
}
}
--- 1422,1443 ----
* @return the nth Accessible child of the object
*/
public Accessible getAccessibleChild(int i) {
Component[] children = getMenuComponents();
int count = 0;
! for (Component child : children) {
! if (child instanceof Accessible) {
if (count == i) {
! if (child instanceof JComponent) {
// FIXME: [[[WDW - probably should set this when
// the component is added to the menu. I tried
// to do this in most cases, but the separators
// added by addSeparator are hard to get to.]]]
! AccessibleContext ac = child.getAccessibleContext();
ac.setAccessibleParent(JMenu.this);
}
! return (Accessible) child;
} else {
count++;
}
}
}
*** 1579,1589 ****
if (i < 0 || i >= getItemCount()) {
return;
}
JMenuItem mi = getItem(i);
if (mi != null && mi instanceof JMenu) {
! if (((JMenu) mi).isSelected()) {
MenuElement old[] =
MenuSelectionManager.defaultManager().getSelectedPath();
MenuElement me[] = new MenuElement[old.length-2];
for (int j = 0; j < old.length -2; j++) {
me[j] = old[j];
--- 1577,1587 ----
if (i < 0 || i >= getItemCount()) {
return;
}
JMenuItem mi = getItem(i);
if (mi != null && mi instanceof JMenu) {
! if (mi.isSelected()) {
MenuElement old[] =
MenuSelectionManager.defaultManager().getSelectedPath();
MenuElement me[] = new MenuElement[old.length-2];
for (int j = 0; j < old.length -2; j++) {
me[j] = old[j];
< prev index next >