We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › awt menu - handling event in menuItem
Page Index Toggle Pages: 1
awt menu - handling event in menuItem (Read 674 times)
awt menu - handling event in menuItem
Sep 28th, 2006, 3:33am
 
hello,

Any advice to get handle mouse event in each MenuItem for call a functions to the sketch.

Code:

import java.awt.*;
import java.awt.event.*;

MenuBar mbarra;
Menu m;
c mc;

void setup(){
size(400,400);
mc = new c();
mc.start();

}
void draw(){
background(200,30,100);
fill(34,150,25);
rect(10,50,50,300);
}

class c extends Frame {

MenuBar mb;
Menu fm,hlp;
MenuItem about,faq,exit;

void c(){
frame = new Frame();
}

void start(){

mb = new MenuBar();
mb.add(fm = new Menu("File"));
fm.add(exit = new MenuItem("Exit"));
mb.add(hlp = new Menu("Help"));
hlp.add(faq = new MenuItem("Faq"));
hlp.add(about = new MenuItem("About"));
frame.setMenuBar(mb);
println(frame.getTitle());
}


public boolean handleEvent( Event evt ) {
System.out.print ("menu");

return false;
}

public boolean action( Event evt,Object obj ) {
System.out.print ("menu");

return false ;
}

}


cheers,

mar
Page Index Toggle Pages: 1