# Problem with colors

**URL:** <https://discourse.processing.org/t/problem-with-colors/5241>\
**Category:** Coding Questions\
**Created:** [November 5, 2018, 9:47pm UTC](https://discourse.processing.org/t/problem-with-colors/5241 "2018-11-05T21:47:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikany](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@mikany](https://discourse.processing.org/u/mikany)\
**Post date:** [November 5, 2018, 9:47pm UTC](https://discourse.processing.org/t/problem-with-colors/5241/1 "2018-11-05T21:47:41Z")

</div>

Hi my project is a little paint program but i have problems with the colorChooser in java , for change of color , to change color, pressing the color button opens chooser color but does not change it.

> [@lerpColor and float\[\] values do not seem to change](https://discourse.processing.org/t/lerpcolor-and-float-values-do-not-seem-to-change/5207/1):
>
> ```auto
> import javax.swing.JColorChooser;
> import java.awt.Color; 
> 
> color c=color(0);
> int x, y, xp, yp;
> int strokeW=6,flag=0; // grosor de la linea , bandera para que se active el mousedragged
> int x1=20, y2=20, w=50, h=30;//medidas del boton borrar
> int x3=80, y3=20, w3=60, h3=30;//medidas del boton guardar
> int x4=150, y4=20, w4=60, h4=30;//medidas del boton color
> PFont mifont;
> 
> void setup()
> {
> mifont = loadFont("Monospaced-48.vlw");
> textFont(mifont, 11);
> background(255);
> size(640, 480);
> background(255);
> }
> void draw()
> {
> buttonborrar();
> buttonguardar();
> buttoncolor();
> noStroke();
> fill(c);
> 
> stroke(c);
> strokeWeight(strokeW);
> //en este caso será para pintar la linea 
> if(flag==1) line(mouseX, mouseY, pmouseX, pmouseY);
> }
> // se llama una vez cada vez que el mouse se mueve mientras se presiona un botón del mouse.
>  
> void mouseDragged() {
> flag=1;
> }
> void mouseReleased(){
> flag=0;
> }
>  
> void buttonborrar ()
> {
> // 1. Dibujar el boton borde negro relleno gris
> fill(128);
> noStroke();
> rect(x1, y2, w, h);
> // 2. Dibujar el texto del boton color negro
> fill(0);
> text("borrar", x1+6, y2+h-10);
> // verificar si se dio click en el boton
> if(mouseX > x1 && mouseX < x1+w && mouseY > y2 && mouseY < y2+h && mousePressed==true) {
> // si hubo click en el botón borrar la pantalla con color blanco
> background(255); 
> } 
> // seleccionar color de relleno gris
> fill(200);
> // desconectar el borde
> noStroke();
> }
> 
> void buttonguardar()
> {
> fill(128);
> noStroke();
> rect(x3, y3, w3, h3);
> // 2. Dibujar el texto del boton color negro
> fill(0);
> text("GUARDAR", x3+6, y3+h3-10);
> // verificar si se dio click en el boton
> if(mouseX > x3 && mouseX < x3+w3 && mouseY > y3 && mouseY < y3+h3 && mousePressed==true) {
> // si hubo click en el botón guardar se guardara la imagen en la carpeta 
> fill(255);
> rect(x3, y3, w3, h3);
> saveFrame("img/######.jpg");
> } 
> // seleccionar color de relleno gris
> fill(200);
> // desconectar el borde
> noStroke();
> }
>  
> void buttoncolor()
> {
> color c = color(255,255,255);
> Color javaColor; 
> fill(128);
> noStroke();
> rect(x4, y4, w4, h4);
> // 2. Dibujar el texto del boton color negro
> fill(0);
> text("color", x4+6, y4+h4-10);
> // verificar si se dio click en el boton
> if(mouseX > x4 && mouseX < x4+w4 && mouseY > y4 && mouseY < y4+h4 && mousePressed==true) {
> // si hubo click en el botón guardar se guardara la imagen en la carpeta 
> fill(255);
> rect(x4, y4, w4, h4);
> 
> javaColor = JColorChooser.showDialog(null,"color",Color.white);
> if(javaColor!=null)
> {
> c= color(javaColor.getRed(),javaColor.getGreen(),javaColor.getBlue());
> fill(c);
> line(mouseX+width/2, mouseY+width/2, pmouseX+width/2, pmouseY+width/2);
> }
> } 
> // seleccionar color de relleno gris
> fill(200);
> // desconectar el borde
> noStroke();
> }
> 
> ```
> 
> please a need help

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [November 5, 2018, 10:08pm UTC](https://discourse.processing.org/t/problem-with-colors/5241/2 "2018-11-05T22:08:44Z")

</div>

Have you tried [debugging your code](https://happycoding.io/tutorials/processing/debugging)?

Have you checked the value of `javaColor`? Is it non-null? What are its red, green, and blue components? Are they all what you expected?

Try to get something simpler working. Can you write an example sketch that hard-codes a Java `Color` and translates it to a Processing `color`? Then make it so the color is from a color chooser. Work your way forward in small steps like that.
