# From Java to simple Desktop Application?

**URL:** <https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582>\
**Category:** Coding Questions\
**Created:** [August 25, 2019, 4:58am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582 "2019-08-25T04:58:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/eric/32/5988_2.png) [@eric](https://discourse.processing.org/u/eric)\
**Post date:** [August 25, 2019, 4:58am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/1 "2019-08-25T04:58:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 25, 2019, 5:13am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/2 "2019-08-25T05:13:17Z")

</div>

> [@eric](#):
>
> how to build a small desktop application

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](https://github.com/processing/processing/wiki/Command-Line) ,  
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 )

---

<div class="post-metadata">

**Author:** ![eric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/eric/32/5988_2.png) [@eric](https://discourse.processing.org/u/eric)\
**Post date:** [August 25, 2019, 5:26am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/3 "2019-08-25T05:26:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 25, 2019, 5:32am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/4 "2019-08-25T05:32:45Z")

</div>

shortest way would be to change  
`println(info)` to

```auto
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**
>
> ```auto
> /*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 …

---

<div class="post-metadata">

**Author:** ![eric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/eric/32/5988_2.png) [@eric](https://discourse.processing.org/u/eric)\
**Post date:** [August 25, 2019, 6:41am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/5 "2019-08-25T06:41:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 25, 2019, 6:44am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/6 "2019-08-25T06:44:21Z")

</div>

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

* * *

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

---

<div class="post-metadata">

**Author:** ![eric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/eric/32/5988_2.png) [@eric](https://discourse.processing.org/u/eric)\
**Post date:** [August 25, 2019, 7:01am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/7 "2019-08-25T07:01:44Z")

</div>

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.

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 25, 2019, 7:06am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/8 "2019-08-25T07:06:14Z")

</div>

you might want to update the string variable first:

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![eric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/eric/32/5988_2.png) [@eric](https://discourse.processing.org/u/eric)\
**Post date:** [August 25, 2019, 7:09am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/9 "2019-08-25T07:09:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 25, 2019, 7:11am UTC](https://discourse.processing.org/t/from-java-to-simple-desktop-application/13582/10 "2019-08-25T07:11:09Z")

</div>

LOL, here 2 PM, good i could help
