java - How to dynamically resize a Canvas inside a BorderPane with JavaFX -


i've been using swing long time , starting javafx. i'm having trouble figuring out how create resizable painting area.

what i'd equivalent swing code:

jpanel parent = new jpanel(new borderlayout()); jpanel drawarea = new jpanel(){     protected void paintcomponent(graphics g)     {         g.setcolor(color.white);         g.fillrect(0, 0, getwidth(), getheight());         g.setcolor(color.red);         g.drawline(0, 0, getwidth(), getheight());         g.drawline(getwidth(), 0, 0, getheight());     } }; parent.add(drawarea, borderlayout.center); 

this nicely scale fit parent container whenever change size.

i'm trying same in javafx using borderpane parent , canvas inner control, based on code here:

http://www.javacodegeeks.com/2014/04/javafx-tip-1-resizable-canvas.html

this works setting canvas dimensions of parent component whenever change - however, prevents canvas shrinking when the parent ought shrink since parent size includes child canvas size. way example work if canvas uses stage directly parent. seems lot of work set up.

is there way simple jpanel-like component automatically fit parent , let me catch resize event can repaint it?


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -