Using JavaFX 2, I have a basic example of a ScrollPane
that contains an HBox
of Label
s. I want to be able to add a Label
to
you can bind to Hbox widthproperty chnages .
Sample Code :
//in start method add this code
DoubleProperty wProperty = new SimpleDoubleProperty();
wProperty.bind(chatBox.widthProperty()); // bind to Hbox width chnages
wProperty.addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
//when ever Hbox width chnages set ScrollPane Hvalue
chatBoxScrollPane.setHvalue(chatBoxScrollPane.getHmax());
}
}) ;
and
// remove below line from your addChatItem() method
chatBoxScrollPane.setHvalue(chatBoxScrollPane.getHmax());
Result :yes added numbering for fun ;)