Я пытаюсь загрузить файл af xml в borderPane
.
, а borderPane
находится внутри контроллера af xml (это как загрузка af xml в f xml) но у меня белый экран
это код:
package gui;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import java.io.IOException;
import java.net.URL;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.stage.Stage;
public class CompanyMainC extends Application
{
private Stage primaryStage;
private AnchorPane mainLayout;
@FXML
private AnchorPane mainProgramPane;
@FXML
private Label headlineLable;
@FXML
private BorderPane whiteBorderPane;
private URL path;
@FXML
void handleHomeButtonClick(ActionEvent event)
{
FxmlLoader object = new FxmlLoader();
Pane view = object.getPage("CompanyHome");
whiteBorderPane.setCenter(view);
}
@FXML
void handleHomeHeatingButtonClick(ActionEvent event)
{
FxmlLoader object = new FxmlLoader();
Pane view = object.getPage("CompanyHomeHeatingMain");
whiteBorderPane.setCenter(view);
}
@FXML
void handleMessagesButtonClick(ActionEvent event)
{
FxmlLoader object = new FxmlLoader();
Pane view = object.getPage("CompanyMessagesMain");
whiteBorderPane.setCenter(view);
}
@Override
public void start(Stage primaryStage) throws IOException
{ this.primaryStage = primaryStage;
this.primaryStage.setTitle("MyFuel App");
initializeView();
}
private void initializeView() throws IOException
{
// load everything we are doing in the scene builder
FXMLLoader loader = new FXMLLoader();
loader.setLocation(ClientMainC.class.getResource("/gui/CompanyMainView.fxml"));
mainLayout = loader.load();
Scene scene = new Scene(mainLayout);
primaryStage.setScene(scene);
primaryStage.show();
FXMLLoader loader2 = new FXMLLoader();
path = getClass().getResource("CompanyHome.fxml");
try {
loader2.setLocation(path);
whiteBorderPane=new BorderPane();
whiteBorderPane.setCenter(loader2.load());
} catch (IOException e){
System.out.println("Not found: " + path);
e.printStackTrace();
}
}
public static void main(String[] args)
{
launch(args);
}
}
У меня белый экран внутри companyMainView
, но я хочу видеть CompanyHome
внутри CompanyMainView
после запуска проекта (без нажатия кнопок)
Спасибо за помощь