To paint on the canvas, you need to respond to the PAINT_EVENT, which is generated from a canvas when paint is called.
To respond, add code to the handleEvent() function of the object containing the canvas or to the handleEvent() function contained in your project group file (project-name.java).
For example, if you have a canvas component called canvas1, you can add paint behavior to the group file by entering the following code:
public boolean handleEvent(Message msg, Event evt) { switch (evt.id) { case PAINT_EVENT: if (msg.target == gui.canvas1) { // create canvas object and graphics object VJCanvas vjcanvas = (VJCanvas)gui.canvas1.getBody(); Graphics g = vjcanvas.getGrahpics(); // call your paint function here } } return super.handleEvent(msg, evt); }
minHeight |
Minimum height (in pixels) of the canvas. |
minWidth |
Minimum width (in pixels) of the canvas. |
See also: