User Tools

Site Tools


Processing Tutorial

Part 4: Java Mode

In Java mode, you can develop complete Java programs with classes, methods, and most anything. However, you cannot develop stand-alone Java apps in Processing. All Processing sketches are essentially applets, governed by the Processing system class PApplet.

To write a sketch in Java Mode, start by writing a class that extends PApplet:

public class MyDemo extends PApplet
{ ...

Now that your program has its own class name, you can reference it from other programs, and you can re-use it in other applications.

Also, any Processing sketch (in any mode) can be made up of multiple files using tabs. A new tab is created by clicking the right-arrow button on the right hand side of the tab bar (the bar which contains your sketch's name).

However, the Processing reference cautions that this mode is not really recommended. There are tricky issues in communicating values/methods across Java files that take a solid understanding of the Java language to get right. Java code can be added to a sketch written for Continuous mode using the tabs described above. This removes some of Processing's limitations - you can now use Processing utilities without being constrained to one of Processing's PApplet windows. This means that you can write a program that uses one of Processing's windows as an embedded object, etc.

Prev: Part 3- Continuous Mode | Next: Part 5- Running Programs

part_4-_java_mode.txt · Last modified: 2007/09/13 11:43 by scarl