Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setFill(Color) via either a Source object or Id = ((Node)Source.getId()

sgroenJul 26 2015 — edited Jul 26 2015

I am able to execute the following code to get the Style Id assigned to a variable:

public void pixelClicked(javafx.scene.input.MouseEvent event){

  Object source = event.getSource();

   if(source != null){

   pixelIdentification = ((Node)source).getId();

  }

  System.out.println("PixelID is " + pixelIdentification);

  System.out.println("Source is " + source);

  System.out.println("Variable pixelColor is " + pixelColor);

The print out is:

PixelID is 11

Source is Circle[id=11, centerX=0.0, centerY=0.0, radius=10.0, fill=0xa9a9a9ff, stroke=0x000000ff, strokeWidth=1.0]

Variable pixelColor is 0xff0000ff

I need to also change the background color of the Object which is a Circle but after I can't get the correct code.  My best idea is:

               source.setFill(pixelColor);

but the error is setFill is not recognized.

Could someone explain, with the data retrieved above, what code would change the background color of the Circle Object?


This post has been answered by bouye-JavaNet on Jul 26 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2015
Added on Jul 26 2015
2 comments
2,338 views