Im creating raws of images to be selected by the user. I want the image to change its colour once the user clicks on it
FileInputStream seats_fileInputStream = new FileInputStream("seat.png");
Image seats_image = new Image(seats_fileInputStream,50,50,false,false);
ImageView[] seats = new ImageView[30];
for(int i = 0;i<30;i++){
seats[i] = new ImageView(seats_image);
}
HBox seatsRaw_hbox[] = new HBox[5];
VBox seatsLine_vbox = new VBox();
int seatsCount = 0;
for(int i=0;i<5;i++){
seatsRaw_hbox[i]= new HBox();
for(int j=0;j<6;j++){
seatsRaw_hbox[i].getChildren().addAll(seats[seatsCount]);
seatsCount++;
}
seatsLine_vbox.getChildren().add(seatsRaw_hbox[i]);
}
BorderPane Test = new BorderPane();
Test.setCenter(seatsLine_vbox);
Im trying to change the image to green color once it being click:
Color targetColor = Color.GREEN;
ColorAdjust colorAdjust = new ColorAdjust();
colorAdjust.setSaturation(targetColor.getSaturation());
colorAdjust.setHue(targetColor.getHue());
colorAdjust.setBrightness(targetColor.getBrightness());
seats[0].setOnMouseClicked(e->{
seats[0].setEffect(colorAdjust);
});
But I keep getting strange colors
The Orginal image:
The strange result I got once I click: