[5394] in java-interest
Menu Events
daemon@ATHENA.MIT.EDU (Dean Burson/CAM/Lotus)
Wed Feb 7 16:59:23 1996
To: java-interest <java-interest@java.sun.com>
Cc: global <global@ctlnet.com>
From: Dean Burson/CAM/Lotus <Dean_Burson/CAM/Lotus.LOTUS@crd.lotus.com>
Date: 7 Feb 96 15:07:59 EST
Hi Mike, I think you need to handle the menu event on the
frame class and not Username.
Add this to your code ...
class myFrame extends Frame
{
myFrame(String title){ super(title);}
public boolean action(Event ev, Object arg) {
System.out.println("Here");
if (ev.target instanceof MenuItem) {
System.out.println("Here");
return true;
}
return false;
}
}
Dean Burson
To: java-interest @ java.sun.com @ INTERNET
cc: (bcc: Dean Burson/CAM/Lotus)
From: global @ ctlnet.com @ INTERNET
Date: 02/01/96 01:10:04 PM
Subject: -No Subject-
Hi all,
I am having a bear of a time trying to the menu events to work. What am I
missing with the following code (just a test program to play around with)?
import java.awt.*;
class Username {
private float wage; // Wage of employee
public static Frame f = new Frame("ArcTest");
public static void main(String args[])
{
Username u = new Username();
u.addmenu(f);
f.resize(300, 300);
f.show();
}
public void addmenu(Frame f) {
MenuBar mymenu = new MenuBar();
Menu fmenu = new Menu("&File",true);
MenuItem open = new MenuItem("&Open");
Event e = new Event(fmenu,567,"Open");
open.postEvent(e);
fmenu.add(open);
fmenu.add("&Save");
fmenu.addSeparator();
Event e2 = new Event(fmenu,587,"Ouit");
MenuItem quit = new MenuItem("E&xit");
quit.postEvent(e2);
fmenu.add(quit);
mymenu.add(fmenu);
Menu emenu = new Menu("&Edit",true);
emenu.add("&Cut");
emenu.add("&Copy");
emenu.add("&Paste");
mymenu.add(emenu);
Menu vmenu = new Menu("&View",true);
vmenu.add("&Toolbar");
vmenu.addSeparator();
vmenu.add("&Zoom In");
vmenu.add("&Zoom Out");
mymenu.add(vmenu);
f.setMenuBar(mymenu);
}
public boolean action(Event ev, Object arg) {
System.out.println("Here");
if (ev.target instanceof MenuItem) {
System.out.println("Here");
return true;
}
return false;
}
}
Thanks,
Mike
------------------------------------------------------------
Global Trading Company, Inc. Global Systems, Inc.
4115 Clubview Drive Voice: 219-436-5650
Fort Wayne, IN 46804 219-436-8901
email: global@ctlnet.com Fax: 219-436-9720
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com