I have this simple controller:
@FXML
private VBox VVbox;
private ButtonBar newNode = new ButtonBar();
private Circle c= new Circle();
private Button b= new Button();
private Label lname = new Label();
private Label lIMEI = new Label();
private Label lroot = new Label();
@Override
public void initialize(URL location, ResourceBundle resources) {
// TODO Auto-generated method stub
}
public void create(String imei){
System.out.println(imei);
newNode = new ButtonBar();
b = setButtonSpec(imei + "btnHavefun");
c = setCircleSpec(imei + "statuOnline");
lname= setLNameSpec(imei + "name");
lIMEI = setLIMEISpec(imei + "Imei");
lroot = setLrootSpec(imei + "root");
newNode.getButtons().addAll(lname,lIMEI,lroot,b,c);
VVbox.getChildren().addAll(newNode) ;
}
this is my main:
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Thypheon Application");
Connection connessione = new Connection();
Thread t = new Thread(connessione);
initDesign();
t.start();
}
public static void main(String[] args) {
launch(args);
}
public void initDesign(){
try {
loader2= new FXMLLoader(getClass().getResource("Design.fxml"));
AnchorPane anchor = (AnchorPane) loader2.load();
rootLayout.setCenter(anchor);
controller = loader2.getController();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
As you can see in main I start a new thread in which I would like a Controller function.
public class Connection implements Runnable {
String result;
Controller controller = new Controller();
public void run() {
controller.create("TEST123");
}
Everything seems to be inside create function until The last line is executed: VVbox.getChildren().addAll(newNode) ; Probably because it has a reference to the FXML file.. How can I solve this?