< prev index next >
src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java
Print this page
*** 108,117 ****
--- 108,118 ----
private void updateItems() {
final int count = fInvoker.getMenuComponentCount();
final Component[] items = fInvoker.getMenuComponents();
if (needsUpdate(items, childHashArray)) {
removeAll();
+ fItems.clear();
if (count <= 0) return;
childHashArray = new int[count];
for (int i = 0; i < count; i++) {
addItem(items[i]);
*** 244,254 ****
@Override
public void addNotify() {
synchronized (getTreeLock()) {
super.addNotify();
if (fModelPtr == 0) {
! fInvoker.addContainerListener(this);
fInvoker.addComponentListener(this);
fPropertyListener = new ScreenMenuPropertyListener(this);
fInvoker.addPropertyChangeListener(fPropertyListener);
final Icon icon = fInvoker.getIcon();
--- 245,255 ----
@Override
public void addNotify() {
synchronized (getTreeLock()) {
super.addNotify();
if (fModelPtr == 0) {
! fInvoker.getPopupMenu().addContainerListener(this);
fInvoker.addComponentListener(this);
fPropertyListener = new ScreenMenuPropertyListener(this);
fInvoker.addPropertyChangeListener(fPropertyListener);
final Icon icon = fInvoker.getIcon();
*** 279,289 ****
super.removeNotify();
fItems.clear();
if (fModelPtr != 0) {
removeMenuListeners(fModelPtr);
fModelPtr = 0;
! fInvoker.removeContainerListener(this);
fInvoker.removeComponentListener(this);
fInvoker.removePropertyChangeListener(fPropertyListener);
}
}
}
--- 280,290 ----
super.removeNotify();
fItems.clear();
if (fModelPtr != 0) {
removeMenuListeners(fModelPtr);
fModelPtr = 0;
! fInvoker.getPopupMenu().removeContainerListener(this);
fInvoker.removeComponentListener(this);
fInvoker.removePropertyChangeListener(fPropertyListener);
}
}
}
*** 300,314 ****
* Invoked when a component has been removed from the container.
*/
@Override
public void componentRemoved(final ContainerEvent e) {
final Component child = e.getChild();
! final MenuItem sm = fItems.get(child);
if (sm == null) return;
remove(sm);
- fItems.remove(sm);
}
/**
* Invoked when the component's size changes.
*/
--- 301,314 ----
* Invoked when a component has been removed from the container.
*/
@Override
public void componentRemoved(final ContainerEvent e) {
final Component child = e.getChild();
! final MenuItem sm = fItems.remove(child);
if (sm == null) return;
remove(sm);
}
/**
* Invoked when the component's size changes.
*/
< prev index next >