From Java to simple Desktop Application?

I built a relatively simple application that measures a cross section, counts “folds” and then determines a color to white percentage. Hard to explain with little detail. My objective is to have a simple desktop app that you open up, import a photo, the photo opens up on the page, you click on the center of the photo and then the data values are given to you maybe in a separate window or the same, doesn’t matter.
I have zero clue how to build a small desktop application, any experience or advice to point me in the right direction is much appreciated.

1 Like

you work here with Processing IDE 3.5.3 ?
did you try to


/File/Export Application/ [enable] embed JAVA for XXX /


also you can start Processing “your sketch” from command line
Command Line · processing/processing Wiki · GitHub ,
in both cases you have your canvas window ( and not the Processing IDE window )


is that what you look for?

note: both will use your sketch ( in source / uncompiled form )

2 Likes

Ah, that’s exactly what I wanted. Although how would I view the console? Because previously I printed the data to the console, and I want that data to show up.
Thanks

shortest way would be to change
println(info) to

boolean console = false;
String info="that's what i have to say";

if ( console ) text(info,10,height-20);

void keyPressed() {
 if ( key == 'p' ) console = ! console;
}
example
/*start from Examples : Basics / Image / LoadDisplayImage */

PImage img;
float fset = 0.50;
boolean fenable = false;
boolean console = true;
String info="mouse click toggle enable filter\n key [f] and turn mousewheel\n key [p] toggle info print";
String mwpp="MouseWheelPlusPlus by KLL";

void setup() {
  size(640, 360);
  img = loadImage("moonwalk.jpg");  // Load the image into the program
}

void draw() {
  image(img, 0, 0);
  if ( fenable ) filter(THRESHOLD, fset);
  infoprint(info);
}
void mouseWheel(MouseEvent event) {
  float e = event.getCount(); //println(e);
  if ( keyPressed && key == 'f' ) { 
    fset += e/30.0 ;
    constrain(fset, 0, 1);
    mwpp = " key f: fset "+nf(fset,0,2);
  }
}

void mousePressed() {
  fenable = ! fenable;
}

void keyPressed() {
  if ( key == 'p' ) console = ! console;
}

void infoprint(String txt) {
  if ( console ) {
    noStroke();
    fill(200);
    rect(0, height-60, 200, height);
    fill(200, 0, 0);
    text(txt, 10, height-50);
    fill(0, 200, 200);
    text(mwpp,10, height-8);
  }
}

a long way would be a second window …

2 Likes

Thanks, I grasped that concept.
I’m running into a problem where I have a global float, then within function I change that value. I can print it just fine to the console, but I when I try and display it, it isn’t updated and is just 0.0.
Any ideas?

any problem with the nf(float,leading,decimales) function
https://processing.org/reference/nf_.html


please post your code here / using: </> "Preformatted text" Code tag

1 Like

Ah, I did not know about that function. Unfortunately it isn’t the issue in this situation but is helpful for the project.
I’ll try and write a mock up of the general idea that I have that isn’t working, all in all it’s over 1000 lines.

Ok, with my limited knowledge, I would assume this to output “Measurement: 4 inches”, but it’s still not updating and is 0.0.

float cabbageWidth = 0;
String widthCabbage = "Measurement: "+cabbageWidth+" inches";
int clickCount = 0;
void setup () {
  size(500, 500);
}
void draw() {
  if (clickCount > 3) {
    infoPrint();
  }
}
void mouseClicked() {
  measureCabbage();
  clickCount++;
}
void measureCabbage() {
  cabbageWidth++;
}

void infoPrint() {
  noStroke();
  fill(75, 200, 75, 50);
  rect(0, height-150, 250, height);
  fill(0);
  text(widthCabbage, 10, height-125);
}

you might want to update the string variable first:

void infoPrint() {
  noStroke();
  fill(75, 200, 75, 50);
  rect(0, height-150, 250, height);
  fill(0);
  widthCabbage = "Measurement: "+cabbageWidth+" inches";
  text(widthCabbage, 10, height-125);
}
3 Likes

You my friend are a life saver. That is incredible how fast you saved my code haha.
Much appreciated. It’s 2 am my time, I gotta get to bed.

2 Likes

LOL, here 2 PM, good i could help