problem runing this code
in
Android Processing
•
1 year ago
this code runs on standard mide but in android mode it gives me error ! can anybody tell me what's the problem ? I found that
here . I want to add a menu to my app and this code seems to be what I need how can I solve this error ?
- import java.awt.event.*;
- import java.awt.*;
- import javax.swing.*;
- //how to create a menubar with hotkeys
- Menu fm;
- MenuItem ol,sl;
- int i;
- void setup(){
- size(400,400);
- this.frame.setTitle("example: a menubar with hotkeys");
- MenuBar mb = new MenuBar();
- mb.add(fm = new Menu("File"));
- fm.add(ol = new RedirectingMenuItem(this,"Open", new MenuShortcut( KeyEvent.VK_O )));
- fm.add(sl = new RedirectingMenuItem(this,"Save", new MenuShortcut( KeyEvent.VK_S )));
- this.frame.setMenuBar(mb);
- background(0);
- }
- void draw(){
- background(i%=255);
- i++;
- }
- boolean action(Event e, Object arg) {
- if (e.target == ol) {
- println("Here's where you would put your file loading code.");
- return true;
- }
- else if (e.target == sl) {
- println("And here's where you would save.");
- }
- return super.action(e,arg);
- }
- public class RedirectingMenuItem extends MenuItem {
- private Component event_handler;
- public RedirectingMenuItem(Component event_handler, String label, MenuShortcut hotkey) {
- super(label,hotkey);
- this.event_handler = event_handler;
- }
- public boolean postEvent(Event e) {
- if (event_handler.isValid()) return event_handler.postEvent(e);
- else return false;
- }
- }
- [javac] Compiling 2 source files to C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android3671928582931527343.pde\bin\classes
- [javac] C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android3671928582931527343.pde\src\changethispackage\beforesubmitting\tothemarket\sketch_jul04a\sketch_jul04a.java:62: cannot find symbol
- [javac] symbol : variable frame
- [javac] location: class changethispackage.beforesubmitting.tothemarket.sketch_jul04a.sketch_jul04a
- [javac] frame.setMenuBar(myMenu);
- [javac] ^
- [javac] 1 error
1