2004-01-27 Kim Ho <kho@redhat.com>

* gnu/java/awt/peer/gtk/GtkFramePeer.java
        (removeMenuBarPeer): Remove MenuBarPeer argument.
        * gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
        (dispose): Call native method.
        * java/awt/Frame.java (setMenuBar): Create and remove
        MenuBar peers only if the Frame has a peer.
        (addNotify): Create the MenuBar peer if one exists.
        (removeNotify): Remove MenuBar peer if one exists.
        * java/awt/Menu.java: Fix imports.
        (addNotify): Don't use full class name.
        (removeNotify): Call removeNotify on all children.
        * java/awt/MenuBar.java (removeNotify): Call
        removeNotify on all children.
        * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
        (removeMenuBarPeer): Remove MenuBarPeer argument.
        Iterate through children to find the Frame's MenuBar.
        * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
        New file.
        (dispose): Remove references to the MenuComponent.

From-SVN: r76740
This commit is contained in:
Kim Ho 2004-01-27 19:29:57 +00:00 committed by Kim Ho
parent 69a4504000
commit e300e74f17
10 changed files with 139 additions and 13 deletions

View file

@ -341,11 +341,15 @@ getMenuBar()
public synchronized void
setMenuBar(MenuBar menuBar)
{
this.menuBar = menuBar;
if (menuBar != null)
menuBar.addNotify();
if (peer != null)
{
if (this.menuBar != null)
this.menuBar.removeNotify();
if (menuBar != null)
menuBar.addNotify();
((FramePeer) peer).setMenuBar(menuBar);
}
this.menuBar = menuBar;
}
/*************************************************************************/
@ -432,11 +436,20 @@ remove(MenuComponent menu)
public void
addNotify()
{
if (menuBar != null)
menuBar.addNotify();
if (peer == null)
peer = getToolkit ().createFrame (this);
super.addNotify();
}
public void removeNotify()
{
if (menuBar != null)
menuBar.removeNotify();
super.removeNotify();
}
/*************************************************************************/
/**

View file

@ -41,6 +41,7 @@ package java.awt;
import java.awt.peer.MenuPeer;
import java.io.Serializable;
import java.util.Vector;
import java.util.Enumeration;
/**
* This class represents a pull down or tear off menu in Java's AWT.
@ -379,7 +380,7 @@ addNotify()
{
if (peer == null)
peer = getToolkit().createMenu(this);
java.util.Enumeration e = items.elements();
Enumeration e = items.elements();
while (e.hasMoreElements())
{
MenuItem mi = (MenuItem)e.nextElement();
@ -396,6 +397,12 @@ addNotify()
public void
removeNotify()
{
Enumeration e = items.elements();
while (e.hasMoreElements())
{
MenuItem mi = (MenuItem) e.nextElement();
mi.removeNotify();
}
super.removeNotify();
}

View file

@ -279,6 +279,12 @@ addNotify()
public void
removeNotify()
{
Enumeration e = menus.elements();
while (e.hasMoreElements())
{
Menu mi = (Menu) e.nextElement();
mi.removeNotify();
}
super.removeNotify();
}