javafx 8 - Size of TableView in a VBox -



javafx 8 - Size of TableView in a VBox -

i want layout resizable chart @ top , fixed size table @ bottom. tried using vbox chart , tableview, vbox.setvgrow ensure resizing goes on chart. know in advance have 3 rows in table.

however, table firstly shows more rows have, , secondly, resizes when resize main window.

i using jdk8, update 31, on windows 8.1/64-bit.

i'm setting stage this

public void start(stage primarystage) { linechart<number, number> chart = new linechart<>(new numberaxis(), new numberaxis()); node table = maketable(); vbox.setvgrow(chart, priority.always); vbox.setvgrow(table, priority.never); vbox root = new vbox( chart, table); scene scene = new scene(root, 300, 250); primarystage.setscene(scene); primarystage.show(); }

and table initialised (note: stuff color have info set in table)

private static node maketable() { tableview<color> table = new tableview<>(fxcollections.observablearraylist(color.aliceblue, color.chartreuse, color.goldenrod)); tablecolumn<color, double> col1 = new tablecolumn<>("red"); tablecolumn<color, double> col2 = new tablecolumn<>("green"); tablecolumn<color, double> col3 = new tablecolumn<>("blue"); col1.setcellvaluefactory(new propertyvaluefactory<>("red")); col2.setcellvaluefactory(new propertyvaluefactory<>("green")); col3.setcellvaluefactory(new propertyvaluefactory<>("blue")); table.setcolumnresizepolicy(tableview.constrained_resize_policy); table.getcolumns().setall(arrays.aslist(col1, col2, col3)); homecoming table; }

is there way resize table content , prepare there?

i have tried setmaxheight , setprefheight use_pref_size , use_computed_size on table no effect

the table firstly shows more rows have

this default style of tableview. can hide them customizing css of table cell. problem arises, tableview still show empty area there no rows. both of these problems can workarounded if number or items (rows) fixed. can accomplished setting preferred width , height of tableview:

table.setprefsize( 300, 100 );

and secondly, resizes when resize main window

this default behavior of vbox. here putting tableview parent not straight resizable, resolve resizing problem. of time candidate group.

group grouping = new group( table );

additional visually laying out tips are:

align vbox children centered: root.setalignment( pos.center ); give padding vbox: root.setpadding( new insets( 15 ) );

full modifications code:

@override public void start( stage primarystage ) { linechart<number, number> chart = new linechart<>( new numberaxis(), new numberaxis() ); node table = maketable(); grouping group = new group( table ); vbox.setvgrow( chart, priority.always ); vbox.setvgrow( group, priority.never ); vbox root = new vbox( chart, grouping ); root.setalignment( pos.center ); root.setpadding( new insets( 15 ) ); scene scene = new scene( root, 300, 250 ); primarystage.setscene( scene ); primarystage.show(); } private static node maketable() { tableview<color> table = new tableview<>( fxcollections.observablearraylist( color.aliceblue, color.chartreuse, color.goldenrod ) ); tablecolumn<color, double> col1 = new tablecolumn<>( "red" ); tablecolumn<color, double> col2 = new tablecolumn<>( "green" ); tablecolumn<color, double> col3 = new tablecolumn<>( "blue" ); col1.setcellvaluefactory( new propertyvaluefactory<>( "red" ) ); col2.setcellvaluefactory( new propertyvaluefactory<>( "green" ) ); col3.setcellvaluefactory( new propertyvaluefactory<>( "blue" ) ); table.setcolumnresizepolicy( tableview.constrained_resize_policy ); table.setprefsize( 300, 100 ); table.getcolumns().setall( arrays.aslist( col1, col2, col3 ) ); homecoming table; }

javafx-8

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -