How to draw a rectangle over an element on the image using JavaFX? -
i have image displayed on javafx application. given coordinates, must display part on image using rectangle. example, if there textfield on image , give coordinates of textfield, rectangle should appear on textfield on image (just highlighting it). drawing rectangle easy, i'm having difficulty positioning on image. please help.
you should use parent component not layouts children automatically. can use pane:
@override public void start( final stage primarystage ) { imageview imageview = new imageview( ... ); // optional: locating image @ ix-iy // imageview.setx( ix ); // imageview.sety( iy ); rectangle r = new rectangle( rx, ry, width, height ); // add rectangle @ last, shows on top of other children pane pane = new pane( imageview, r ); final scene scene = new scene( pane, 400, 300 ); primarystage.setscene( scene ); primarystage.show(); }
Comments
Post a Comment