hello everyone.
I'm making an application where I have a grid cell. in there i wanna place controls that fille the whole-cell width. i achieved this with a button but i cannot get it to work with my custom control. this is the code i usse for the sizing:
Button b = new Button("delete");
b.setMaxWidth(Double.MAX_VALUE);
GridPane.setFillWidth(b, true);
gridPane.add(b,0,0);
WLAcordionControl w = new WLAcordionControl();
w.controller.Main.setMaxWidth(Double.MAX_VALUE);
GridPane.setFillWidth(w.controller.Main, true);
gridPane.add(w,0,1);
and this is the result i get
link to image
here is the fxml code of my custom control:
="1.0"="UTF-8"
<AnchorPane fx:id="Main" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Accordion AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<panes>
<TitledPane id="Container" fx:id="Container" animated="false" text="untitled 1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TextArea id="text" fx:id="text" layoutX="19.6" layoutY="19.6" prefHeight="354.0" prefWidth="787.0" AnchorPane.bottomAnchor="0.5" AnchorPane.leftAnchor="0.5" AnchorPane.rightAnchor="0.5" AnchorPane.topAnchor="10.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</AnchorPane>
the code of my customcontrol's controller
package ArticleControls.wlAcordion;
import ArticleControls.ArticleControl;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
public class WLAcordionController extends ArticleControl {
@FXML
public AnchorPane Main;
public WLAcordionController(){
}
@Override
public Object GetData() {
return null;
}
}
and this is the code of the custom control itself:
package ArticleControls.wlAcordion;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import java.io.IOException;
public class WLAcordionControl extends AnchorPane {
public WLAcordionController controller;
public WLAcordionControl(){
super();
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("WlAcordion.fxml"));
controller = new WLAcordionController();
loader.setController(controller);
Node n = loader.load();
this.getChildren().add(n);
}
catch (IOException ix){
}
}
}
Thx for helping.
What I have tried:
I originally tried it with a vbox but that also did not work.