UI Component [JavaFX Group] loses its position while the window is resized ... occurs only after scrolling horizontally -


please go through image below.
enter image description here

in above image can find horizontal scrolling not started.
visit after scroll image of same contents...

enter image description here

now in second image can see horizontal scrolling done ...
jfxpanel contents scroll horizontally... perfect...
third image describe problem....

enter image description here

it liitle bit stretched see maximized...
can see jfxpanel contents have changed original position...
contents must start x_displacement = 0.0 [x-cordinate], done automatically in first 2 images...
contents nodes [rectangle,line etc.. ], after placed in group node...
, group node set in scrollpane through

js.setcontent(group node);   

each component placed given x,y cordiante value .. how did happen while doing maximized ?
please me find root cause ...

thanks in advance...

here facts cause problem.

- start position of scene : 0.0  - start position of group in scene : 49.5  - width of root : 364.5    - start position of scene : 0.0  - start position of group in scene : 63.5  - width of root : 364.5   - start position of scene : 0.0  - start position of group in scene : 83.5  - width of root : 364.5  

whenever drag window horizontally group moving in scene... should not happen... how avoid ...

ok... here mcve.....

there frame. contain splitpane having vertical split.
splitpane show contents of 2 jfxpanels.
both fxpanels having rectangle on same x cordinate y cordinate different.
, both fxpanels horizontal scroll sync. not bi-directional. when scroll lower panel horizonatally, upper panel scrolled due horizontal sync.

here code fxpanel 1...

public class fxpanel1 extends jfxpanel { private scrollpane scroll ;   public scrollpane getjs() {     return scroll; } public void setjs(scrollpane js) {     this.scroll = js; }  private boolean initfx(jfxpanel fxpanel) {     scene scene = createscene();            fxpanel.setscene(scene);     return true;     //craneassignmentchartview.setfxpanel(fxpanel);         } private scene createscene() {     group root = new group();      rectangle rect = new rectangle(10.0, 20.0, 800, 40);     rect.setfill(javafx.scene.paint.color.transparent);      rect.setstroke(javafx.scene.paint.color.red);      anchorpane anchor = new anchorpane();     anchor.getchildren().add(rect);      gridpane grid = new gridpane();     grid.sethgap(0);     grid.setvgap(0);     grid.setpadding(new insets(0, 0, 0, 0));             grid.add(anchor, 1, 0);       root.getchildren().add(grid);      scrollpane scroll = new scrollpane();     scroll.sethbarpolicy(scrollbarpolicy.always);     scroll.setvbarpolicy(scrollbarpolicy.as_needed);     scroll.setcontent(root);     setjs(scroll);     return new  scene(scroll, javafx.scene.paint.color.white);       }  private void createui(final jfxpanel fxpanel) {     platform.runlater(new runnable() {          @override         public void run()          {             initfx(fxpanel);                         }     }); } public fxpanel1( jfxpanel fxpanel) {     createui(fxpanel); } } 

now code second fxpanel looks ...

public class fxpanel2 extends jfxpanel { private scrollpane scroll ;  public scrollpane getjs() {     return scroll; } public void setjs(scrollpane js) {     this.scroll = js; } private boolean initfx(jfxpanel fxpanel) {     scene scene = createscene();            fxpanel.setscene(scene);     return true;     //craneassignmentchartview.setfxpanel(fxpanel);         } private scene createscene() {     group root = new group();      rectangle rect = new rectangle(10.0, 180.0, 800, 40);     rect.setfill(javafx.scene.paint.color.transparent);      rect.setstroke(javafx.scene.paint.color.red);      anchorpane anchor = new anchorpane();     anchor.getchildren().add(rect);      gridpane grid = new gridpane();     grid.sethgap(0);     grid.setvgap(0);     grid.setpadding(new insets(0, 0, 0, 0));             grid.add(anchor, 1, 0);       root.getchildren().add(grid);      scrollpane scroll = new scrollpane();     scroll.sethbarpolicy(scrollbarpolicy.always);     scroll.setvbarpolicy(scrollbarpolicy.never);     scroll.setcontent(root);     setjs(scroll);     return new  scene(scroll, javafx.scene.paint.color.white);       }  private void createui(final jfxpanel fxpanel) {     platform.runlater(new runnable() {          @override         public void run()          {             initfx(fxpanel);                         }     }); } public fxpanel2( jfxpanel fxpanel) {     createui(fxpanel); } } 

the main class looks ....

public class demotocheckuialignment extends jframe { public static void main(string[] args) {     final demotocheckuialignment demo = new demotocheckuialignment();     swingutilities.invokelater(new runnable() {         @override         public void run() {              jfxpanel panel1 = new jfxpanel();             fxpanel1 fxobj1 = new fxpanel1(panel1);              jfxpanel panel2 = new jfxpanel();             fxpanel2 fxobj2 = new fxpanel2(panel2);              demotocheckuialignment frame = new demotocheckuialignment();             frame.setsize(800, 500);                            frame.setdefaultcloseoperation(jframe.exit_on_close);                jsplitpane chartsplitpane = new jsplitpane();             chartsplitpane.setorientation(jsplitpane.vertical_split);             chartsplitpane.setdividerlocation(200);             chartsplitpane.setdividersize(2);             chartsplitpane.settopcomponent(panel1);             chartsplitpane.setbottomcomponent(panel2);              demo.providescrollsyncbetweenfxpanels(fxobj1.getjs(), fxobj2.getjs());               frame.getcontentpane().add(chartsplitpane);             //frame.getcontentpane().add(panel2);             frame.setvisible(true);         }     }); }   public static void providescrollsyncbetweenfxpanels(final scrollpane uppersp, final scrollpane lowersp) {                         lowersp.hvalueproperty().addlistener(new changelistener<number>()              {                                public void changed(observablevalue<? extends number> ov,                         number old_val, number new_val)                  {                     uppersp.hvalueproperty().set(new_val.doublevalue());                 }             }); } } 

now check problem follow simple steps...
ofcorse run program...
scroll bottom panel ....that fxpanel2...
, maximized window .... x - position inner contents changed now...
not happen swing....

here screen shots problem reproduce attached mcve....please go through images....

enter image description here

enter image description here

enter image description here

you may use setfittowidth of scrollpane object match particular dimension. more details may refer link http://docs.oracle.com/javafx/2/ui_controls/scrollpane.htm @ down page, resizing components in scroll pane, may find more on solution


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -