Hello.
as far as I understand, objects of MenuItem and its subclasses can be
added to a Menu. that means PopupMenu can be added to a Menu too since
PopupMenu is a subclass of MenuItem. so I wrote the following
test code and it compiles. but I couldn't see the popup menu showing on my
menubar. can anyone tell me why? thanks a lot.
cw
===============================
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class A extends Frame {
public static void main(
String[] args) {
Frame a = new A();
MenuBar mb = new MenuBar();
Menu m = new Menu("Menu");
CheckboxMenuItem cbmi = new CheckboxMenuItem("check");
MenuItem mi1 = new MenuItem("first");
MenuItem mi2 = new MenuItem("second");
PopupMenu pm = new PopupMenu("Pop");
pm.add("pop1");
pm.add("pop2");
m.add(cbmi);
m.add(mi1);
m.add(mi2);
m.add(pm);
mb.add(m);
a.setMenuBar(mb);
a.setSize(250,250);
a.setVisible(true);
}
}