-
-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestpinnedThis may be useful because GitHub allows up to 3 pinned issuesThis may be useful because GitHub allows up to 3 pinned issues
Description
Describe the bug
When the text is set via a controller method, sometimes the MFXTextField component does not update.
MRE(Minimal Reproducible Example)
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws IOException {
var main = controllerLoader("main.fxml");
Parent root = main.load();
var spOne = controllerLoader("sp-one.fxml");
Parent startView = spOne.load();
SpOne controller = spOne.getController();
controller.setup("someText");
var sp = (SplitPane) root.lookup("#splitPane");
sp.getItems().set(0, startView);
Scene scene = new Scene(root, 500, 500);
primaryStage.setScene(scene);
primaryStage.show();
sp.setDividerPosition(0, 1);
}
private FXMLLoader controllerLoader(String path) {
return new FXMLLoader(Main.class.getResource(path));
}
}main.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox prefHeight="400" prefWidth="600"
xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.example.Main">
<SplitPane fx:id="splitPane" orientation="VERTICAL" VBox.vgrow="ALWAYS">
<AnchorPane/>
<AnchorPane/>
</SplitPane>
</VBox>sp-one.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import io.github.palexdev.materialfx.controls.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<ScrollPane fitToWidth="true" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.example.SpOne">
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="NEVER" maxWidth="30.0" minWidth="30.0" prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="350" />
<ColumnConstraints hgrow="NEVER" maxWidth="30.0" minWidth="30.0" prefWidth="30.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="60.0" minHeight="60.0" prefHeight="60.0" valignment="CENTER" vgrow="NEVER" />
<RowConstraints valignment="CENTER" vgrow="ALWAYS" />
<RowConstraints maxHeight="80.0" minHeight="80.0" prefHeight="80.0" valignment="CENTER" vgrow="NEVER" />
<RowConstraints />
</rowConstraints>
<children>
<VBox spacing="20.0" GridPane.columnIndex="1" GridPane.columnSpan="1" GridPane.rowIndex="1" GridPane.vgrow="SOMETIMES">
<MFXTextField fx:id="address0" floatMode="BORDER" floatingText="address0" maxWidth="5000" prefHeight="40" />
<MFXTextField fx:id="address1" floatMode="BORDER" floatingText="address1" maxWidth="5000" prefHeight="40" />
<MFXTextField fx:id="address2" floatMode="BORDER" floatingText="address2" maxWidth="5000" prefHeight="40" />
<MFXTextField fx:id="address3" floatMode="BORDER" floatingText="address3" maxWidth="5000" prefHeight="40" />
<MFXTextField fx:id="address4" floatMode="BORDER" floatingText="address4" maxWidth="5000" prefHeight="40" />
</VBox>
</children>
</GridPane>
</ScrollPane>SpOne.java
public class SpOne implements Initializable {
public MFXTextField address0;
public MFXTextField address1;
public MFXTextField address2;
public MFXTextField address3;
public MFXTextField address4;
public SpOne() { }
public void setup(String str){
address0.setText(str);
address1.setText(str);
address2.setText(str);
address3.setText(str);
address4.setText(str);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
}
}The problem comes from an optimization in MFXTextFieldSkin.
After removing the skipLayout variable everything works as expected.
I can add a PR if needed, let me know.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestpinnedThis may be useful because GitHub allows up to 3 pinned issuesThis may be useful because GitHub allows up to 3 pinned issues
