2

So I am writing a program that will be used to automination of updating windows machines. Last day I just at saved current working state of program and go home. Today when I tried to work on it I noticed that it is compiling and it is runing without error but non end javaFx GUI is showing up. I spend several ours on trying to repair that. I cleaned the project by eclipse neon.3, I rebuild meaven project, I created new project with new classes and just copy the code into them. I even move project from Eclipse into IntelliJ and run it there. The behavior was the same.

So my main looks like that, nothing special about that. I load main fxml which main object is tableView and some side info.

@Override
public void start(Stage primaryStage) throws IOException, InterruptedException, InvalidFormatException {
    tableList = makeMainList();
    JavaFXmainClass.primaryStage = primaryStage;
    JavaFXmainClass.primaryStage.setTitle("xD Pro Windows Updater Manager Ascendet Master OP xD");
    showMainView();
}

public void showMainView() throws IOException{
    final FXMLLoader loader = new FXMLLoader();
    System.out.println(this.getClass().getResource("fxml//MainView.fxml"));
    loader.setLocation(this.getClass().getResource("fxml//MainView.fxml"));
    mainLayout = loader.load();
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    System.out.println("On the end of showMainView()");
}

public static void main(String[] args) {
    launch(args);
}

In main controler i am initializaing the table in this way.

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    //setting combobox items
    StartTime.getItems().addAll(comboBoxValues);
    EndTime.getItems().addAll(comboBoxValues);
    StartTime.setPromptText("Start Time");
    EndTime.setPromptText("End Time");
    //adding listiner for combobox
    addComboBoxChangeListiner(StartTime, What.STARTTIME);
    addComboBoxChangeListiner(EndTime, What.ENDTIME);

    setColumns();
    mainTable = JavaFXmainClass.getTableList();
    tableList = fromArrayToObservableArray(mainTable, tableList);
    System.out.println(mainTable.size());
    System.out.println("before tableView.setItems");
    tableView.setItems(mainTable);
    System.out.println("after tableView.setItems");
}

private void setColumns() {
    tableView.setFixedCellSize(35);
    id.setCellValueFactory(new PropertyValueFactory<Id,Integer>("id"));
    ip.setCellValueFactory(new PropertyValueFactory<Server,String>("ip"));
    name.setCellValueFactory(new PropertyValueFactory<Server,String>("name"));
    type.setCellValueFactory(new PropertyValueFactory<Server,String>("type"));
    date.setCellValueFactory(new PropertyValueFactory<Server,LocalDate>("date"));
    id.setCellFactory(new LineNumberCellFactory());
    ip.setCellFactory(new getObjectIp());
}

on consol output i can read "after tableView.setItems" and then "On the end of showMainView()" so that means injecting dependencies had ended successfully(i am right ?) and after that without any error program is working but gui is not showing up

fxml is relevent i add as link because it is too large to paste like the rest of samples: https://codepaste.net/z06nzf

GRY GRY
  • 31
  • 2

1 Answers1

2

You forgot to call primaryStage.show(). Your window therefore never becomes visible.

public void showMainView() throws IOException{
    ...
    primaryStage.setScene(scene);
    primaryStage.show();
    System.out.println("On the end of showMainView()");
}
fabian
  • 80,457
  • 12
  • 86
  • 114