0% found this document useful (0 votes)
4 views

Processing - Make PApplet Classes Communicate With Java Code - Stack Overflow

Uploaded by

rud512735
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Processing - Make PApplet Classes Communicate With Java Code - Stack Overflow

Uploaded by

rud512735
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Make PApplet Classes communicate with Java code

Asked 3 years, 2 months ago Modified 3 years, 2 months ago Viewed 523 times

I am trying to use this SDK (for IntelRealSense Cameras) written in Processing in my Java
code. What I did was I took the java source code and made a project with it. So I can run
1 processing sketches directly from my Intellij Java environment using the Processing library.

My question is, can the classes that extend the PApplet class and show the sketches interact
with other classes in the Java code ( that are not PApplet s )? For example, can I create a
Main class to launch both the PApplet sketch and a vanilla Java program as well with them
being able to communicate?

The goal is to to integrate this PApplet source code into an existing Java project as a module
that can transmit information.

All in all, my objective is to : Run concurrently the PApplet and my Java program and transmit
the camera values from the PApplet to my Java Classes.

Is it possible? I mean Processing is Java so It should be, right?

Thank you

java processing

Share Improve this question edited Nov 24, 2019 at 4:03 asked Nov 24, 2019 at 2:12
Follow Kevin Workman mMade
41.2k 9 66 104 25 7

Report this ad

Sorted by:
1 Answer Highest score (default)

Не нашли ответ? Задайте вопрос на Stack Overflow на русском


Не нашли ответ? Задайте вопрос на Stack Overflow на русском.

The short answer to your question is yes it's possible.

3 Shameless self-promotion: here is a tutorial on using Processing from Java.

I recommend you read through that, but in summary, you want to do something like this:

import processing.core.PApplet;

public class MySketch extends PApplet{

public void settings(){


size(500, 500);
}

public void draw(){


ellipse(mouseX, mouseY, 50, 50);
}

public void mousePressed(){


background(64);
}

public static void main(String[] args){


String[] processingArgs = {"MySketch"};
MySketch mySketch = new MySketch();
PApplet.runSketch(processingArgs, mySketch);

// call whatever Java code you want


}
}

Note that the main() method does not have to be in the same class that extends PApplet .

This is all "just" Java, so anything that's valid in Java, is valid in a Java program that uses
Processing as a Java library.

Share Improve this answer Follow answered Nov 24, 2019 at 4:01
Kevin Workman
41.2k 9 66 104

You might also like