A problem with variables or libraries

Hi, I Try to do a radar. But now I have an error: frame cannot be resolved to a variable. May be I have problems with my libryries or something like that. I believe in you guys. If it will help the radar consist of: 2 ultrasonic sensors, 1 servo, 1 arduino nano. And here is the code:
import processing.serial.;
import static javax.swing.JOptionPane.

Serial myPort; // The serial port
String serialin;
int data = new int[360];
PFont f;

final boolean debug = true;

void setup() {
String COMx, COMlist = “”;
size(1280, 720);
f = createFont(“Verdana”, 32, true); // Arial, 16 point, anti-aliasing on
textFont(f, 20);
for (int i = 0; i < 360; i++) {
data[i] = 0;
try {
if (debug) printArray(Serial.list());
int i = Serial.list().length;
if (i != 0) {
if (i >= 2) {
// need to check which port the inst uses -
// for now we’ll just let the user decide
for (int j = 0; j < i; ) {
COMlist += char(j+‘a’) + " = " + Serial.list()[j];
if (++j < i) COMlist += ", ";
COMx = showInputDialog(“Which COM port is correct? (a,b,…):\n”+COMlist);
if (COMx == null) exit();
if (COMx.isEmpty()) exit();
i = int(COMx.toLowerCase().charAt(0) - ‘a’) + 1;
String portName = Serial.list()[i-1];
if (debug) println(portName);
myPort = new Serial(this, portName, 9600); // change baud rate to your liking
myPort.bufferUntil(‘\n’); // buffer until CR/LF appears, but not required…
} else {
showMessageDialog(frame, “Device is not connected to the PC”);
catch (Exception e)
{ //Print the type of error
showMessageDialog(frame, “COM port is not available (may\nbe in use by another program)”);
println(“Error:”, e);

void draw() {
background(26, 26, 36, 200);
stroke(255, 255, 255, 150);
fill(255, 50, 200, 200);
text(“Arduino RADAR 2D Visualization”, 20, 710);
text(hour(), 1050, 710);
text(“:”, 1075, 710);
text(minute(), 1085, 710);
text(“:”, 1110, 710);
text(second(), 1120, 710);
fill(36, 255, 100, 200);
circle(640, 360, 600);
circle(640, 360, 500);
circle(640, 360, 400);
circle(640, 360, 300);
circle(640, 360, 200);
circle(640, 360, 100);

for (int i = 0; i < 360; i++) {
fill(255, 10, 255, 200);
stroke(50, 10, 255, 150);
point(float(640) + (map_values(data[i]))*cos(radians(i)), float(360) + (map_values(data[i]))*sin(radians(i)));

while (myPort.available() > 0) {
serialin = myPort.readStringUntil(10);
try {
String serialdata = splitTokens(serialin, “,”);
if (serialdata[0] != null) {
serialdata[0] = trim(serialdata[0]);
serialdata[1] = trim(serialdata[1]);
serialdata[2] = trim(serialdata[2]);

    int i = int(serialdata[0]);
    data[179-i] = int(serialdata[1]);
    data[(179-i)+180] = int(serialdata[2]);
catch (java.lang.RuntimeException e) {


float map_values(float x) {
float in_min = 0, in_max = 200, out_min = 0, out_max = 700;
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

  1. Add these two imports:

import javax.swing.JFrame;
import javax.swing.JOptionPane;

  1. Inside setup() add this line of code:

JFrame frame = new JFrame();

  1. Call JOptionPane like this:

JOptionPane.showMessageDialog(frame, “COM port is not available (may\nbe in use by another program)”);

Thanks. But where can I find a library for “javax.swing.JFrame” and other. I can’t find them in the processing or on sites.

What do you see when you type java --version into your Terminal utility (Mac)? OpenJDK may be downloaded from here: https://openjdk.org if you don’t have it.

If I understand correctly the previous java version was What should I do with the new file?

I read something about it. But it wouldn’t help me

In order to make a call ‘work’ you usually have to have it installed on your system (or a URL to some web source). I don’t understand why you don’t already have the requisite files. What operating system are you using?

Something you can try:

  1. Instead of supplying a ‘frame’ for the dialog try making it null and see if it will run. For example:


  1. You are still going to need Swing for the JOptionPane, so I think you are going to have to have the files installed on your system either way. You can’t use them if they are not installed. Search the web for installation technique if you don’t know how to do it. For whatever it’s worth I’m using openjdk 20.0.1

May be helpful: https://openjdk.org/install/

I just recently bought a laptop and started studying electronics. so even basic things are difficult for me

I’m already downloaded it. But don’t know, where should I put this file.

Go to https://openjdk.org/install/ and see if you can find your operating system listed there, then do what it says.

The first one was right. You just a god for me. In gratitude, I would like to send you a parcel of sweets from my country. Although it will take a lot of time to figure it all out. But I would still like to thank you somehow. I hope you can understand all of my messages, I’m not a native English speaker

Your gratitude is enough reward for me. It was my pleasure to try and help you. I wish you the best in your future programming endeavors.

1 Like

Don’t think that I forgot about you