javafx.scene.layout.AnchorPane Java Examples

The following examples show how to use javafx.scene.layout.AnchorPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaceholderStageGameMode.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
public void loadRecipes(){
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/poe/level/fx/overlay/RecipeOverlay.fxml"));
    AnchorPane ap = null;
    try {
        ap = loader.load();
    } catch (IOException ex) {
        Logger.getLogger(ZoneOverlay_Stage.class.getName()).log(Level.SEVERE, null, ex);
    }
    loader.<RecipeOverlay_Controller>getController().hookGameModeOn(parent_gameModeOn);

    Scene scene = new Scene(ap);
    scene.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());

    this.setScene(scene);
    //this.setAlwaysOnTop(true);
    this.setOnCloseRequest(event -> {
        RecipeOverlay_Controller.gameModeOn = false;
        this.close();
    });

    this.show();
}
 
Example #2
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private void onSelectMinorStoppagesPareto() throws Exception {
	List<ParetoItem> items = EquipmentLossManager.getParetoData(equipmentLoss, TimeLoss.MINOR_STOPPAGES);

	Number divisor = equipmentLoss.getLoss(TimeLoss.MINOR_STOPPAGES).getSeconds();

	StackPane spMinorStoppagesPareto = new StackPane();

	AnchorPane.setBottomAnchor(spMinorStoppagesPareto, 0.0);
	AnchorPane.setLeftAnchor(spMinorStoppagesPareto, 0.0);
	AnchorPane.setRightAnchor(spMinorStoppagesPareto, 0.0);
	AnchorPane.setTopAnchor(spMinorStoppagesPareto, 0.0);

	apMinorStoppagesPareto.getChildren().clear();
	apMinorStoppagesPareto.getChildren().add(0, spMinorStoppagesPareto);

	ParetoChartController controller = new ParetoChartController();
	controller.createParetoChart(DesignerLocalizer.instance().getLangString("stoppages.pareto"),
			spMinorStoppagesPareto, items, divisor, DesignerLocalizer.instance().getLangString("time.by.reason"));
}
 
Example #3
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private SetupEditorController getSetupController() throws Exception {
	if (setupEditorController == null) {
		FXMLLoader loader = FXMLLoaderFactory.setupEditorLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("setup.editor"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		setupEditorController = loader.getController();
		setupEditorController.setDialogStage(dialogStage);
	}
	return setupEditorController;
}
 
Example #4
Source File: ProposalDisplay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("Duplicates")
public ScrollPane getView() {
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);

    AnchorPane anchorPane = new AnchorPane();
    scrollPane.setContent(anchorPane);

    gridPane.setHgap(5);
    gridPane.setVgap(5);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setPercentWidth(100);

    gridPane.getColumnConstraints().addAll(columnConstraints1);

    AnchorPane.setBottomAnchor(gridPane, 10d);
    AnchorPane.setRightAnchor(gridPane, 10d);
    AnchorPane.setLeftAnchor(gridPane, 10d);
    AnchorPane.setTopAnchor(gridPane, 10d);
    anchorPane.getChildren().add(gridPane);

    return scrollPane;
}
 
Example #5
Source File: TesterApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
public void start(Stage primaryStage) {
	try {
		FXMLLoader loader = FXMLLoaderFactory.testerApplicationLoader();
		AnchorPane mainLayout = loader.getRoot();
		
		testerController = loader.getController();
		testerController.initialize();

		Scene scene = new Scene(mainLayout);

		primaryStage.setTitle(TesterLocalizer.instance().getLangString("test.app.title"));
		primaryStage.getIcons().add(ImageManager.instance().getImage(Images.POINT85));
		primaryStage.setScene(scene);
		primaryStage.show();
	} catch (Exception e) {
		logger.error(e.getMessage());
		stop();
	}
}
 
Example #6
Source File: OperatorController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private Reason showReasonSelector() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.reasonSelectorLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(OperatorLocalizer.instance().getLangString("reason.selector.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	reasonController = loader.getController();
	reasonController.setDialogStage(dialogStage);
	reasonController.initialize();

	if (!reasonController.getDialogStage().isShowing()) {
		reasonController.getDialogStage().showAndWait();
	}
	return reasonController.getSelectedReason();
}
 
Example #7
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private void onSelectSetupPareto() throws Exception {
	List<ParetoItem> items = EquipmentLossManager.getParetoData(equipmentLoss, TimeLoss.SETUP);

	Number divisor = equipmentLoss.getLoss(TimeLoss.SETUP).getSeconds();

	StackPane spSetupPareto = new StackPane();

	AnchorPane.setBottomAnchor(spSetupPareto, 0.0);
	AnchorPane.setLeftAnchor(spSetupPareto, 0.0);
	AnchorPane.setRightAnchor(spSetupPareto, 0.0);
	AnchorPane.setTopAnchor(spSetupPareto, 0.0);

	apSetupPareto.getChildren().clear();
	apSetupPareto.getChildren().add(0, spSetupPareto);

	ParetoChartController controller = new ParetoChartController();
	controller.createParetoChart(DesignerLocalizer.instance().getLangString("setup.pareto"), spSetupPareto, items,
			divisor, DesignerLocalizer.instance().getLangString("time.by.reason"));
}
 
Example #8
Source File: AboutDialog.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new about dialog.
 *
 * @param root root stack pane.
 */
public AboutDialog(StackPane root) {
  super();
  AnchorPane anchor = new AnchorPane();
  anchor.setMaxHeight(274);
  anchor.setMaxWidth(500);
  anchor.setMinHeight(274);
  anchor.setMaxWidth(500);
  ImageView about = Icons.about();
  Label version = new Label(Globals.VERSION);
  Label license = new Label(Globals.LICENSE);
  version.getStyleClass().add("about");
  license.getStyleClass().add("about");
  anchor.setTopAnchor(about, 0.0);
  anchor.setBottomAnchor(about, 0.0);
  anchor.setLeftAnchor(about, 0.0);
  anchor.setRightAnchor(about, 0.0);
  anchor.setTopAnchor(version, 5.0);
  anchor.setRightAnchor(version, 10.0);
  anchor.setBottomAnchor(license, 5.0);
  anchor.setLeftAnchor(license, 10.0);
  anchor.getChildren().addAll(about, version, license);
  setDialogContainer(root);
  setContent((Region) anchor);
  setTransitionType(JFXDialog.DialogTransition.TOP);
}
 
Example #9
Source File: TxIdTextField.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void updateConfidence(TransactionConfidence confidence) {
    GUIUtil.updateConfidence(confidence, progressIndicatorTooltip, txConfidenceIndicator);
    if (confidence != null) {
        if (txConfidenceIndicator.getProgress() != 0) {
            txConfidenceIndicator.setVisible(true);
            AnchorPane.setRightAnchor(txConfidenceIndicator, 0.0);
        }
    } else {
        //TODO we should show some placeholder in case of a tx which we are not aware of but which can be
        // confirmed already. This is for instance the case of the other peers trade fee tx, as it is not related
        // to our wallet we don't have a confidence object but we should show that it is in an unknown state instead
        // of not showing anything which causes confusion that the tx was not broadcasted. Best would be to request
        // it from a block explorer service but that is a bit too heavy for that use case...
        // Maybe a question mark with a tooltip explaining why we don't know about the confidence might be ok...
    }
}
 
Example #10
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
public Material showMaterialEditor() throws Exception {
	if (this.materialController == null) {
		FXMLLoader loader = FXMLLoaderFactory.materialEditorLoader();
		AnchorPane pane = (AnchorPane) loader.getRoot();

		// Create the dialog Stage.
		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("material.editor.title"));
		dialogStage.initModality(Modality.NONE);

		Scene scene = new Scene(pane);
		dialogStage.setScene(scene);

		// get the controller
		materialController = loader.getController();
		materialController.setDialogStage(dialogStage);
		materialController.initialize(this);
	}

	// Show the dialog and wait until the user closes it
	if (!materialController.getDialogStage().isShowing()) {
		materialController.getDialogStage().showAndWait();
	}

	return materialController.getSelectedMaterial();
}
 
Example #11
Source File: XYChart.java    From charts with Apache License 2.0 6 votes vote down vote up
private void adjustAxisAnchors() {
    axis.forEach(axis -> {
        if (Orientation.HORIZONTAL == axis.getOrientation()) {
            AnchorPane.setLeftAnchor(axis, hasLeftYAxis ? leftAxisWidth : 0d);
            AnchorPane.setRightAnchor(axis, hasRightYAxis ? rightAxisWidth : 0d);

            AnchorPane.setLeftAnchor(xyPane, hasLeftYAxis ? leftAxisWidth : 0d);
            AnchorPane.setRightAnchor(xyPane, hasRightYAxis ? rightAxisWidth : 0d);
        } else {
            AnchorPane.setTopAnchor(axis, hasTopXAxis ? topAxisHeight : 0d);
            AnchorPane.setBottomAnchor(axis, hasBottomXAxis ? bottomAxisHeight : 0d);

            AnchorPane.setTopAnchor(xyPane, hasTopXAxis ? topAxisHeight : 0d);
            AnchorPane.setBottomAnchor(xyPane, hasBottomXAxis ? bottomAxisHeight : 0d);
        }
    });
}
 
Example #12
Source File: InfoTextField.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public InfoTextField() {

        arrowLocation = PopOver.ArrowLocation.RIGHT_TOP;
        textField = new BisqTextField();
        textField.setLabelFloat(true);
        textField.setEditable(false);
        textField.textProperty().bind(text);
        textField.setFocusTraversable(false);
        textField.setId("info-field");

        infoIcon = getIcon(AwesomeIcon.INFO_SIGN);
        infoIcon.setLayoutY(5);
        infoIcon.getStyleClass().addAll("icon", "info");

        AnchorPane.setRightAnchor(infoIcon, 7.0);
        AnchorPane.setRightAnchor(textField, 0.0);
        AnchorPane.setLeftAnchor(textField, 0.0);

        hideIcons();

        getChildren().addAll(textField, infoIcon);
    }
 
Example #13
Source File: NewFXPreloader.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
private Scene createPreloaderScene() {
    bar = new ProgressBar();
    //BorderPane p = new BorderPane();
    FXMLLoader loader = new FXMLLoader(getClass().getResource("loading.fxml"));
    AnchorPane p = null;
    try {
        p = loader.load();

    } catch (IOException ex) {
        Logger.getLogger(MainApp_Controller.class.getName()).log(Level.SEVERE, null, ex);
    }

    //at this point this class has done enough, and we need to contact with the 
    //appropriate controllers.
    controller = loader.<Loading_Controller>getController();
    Scene pr = new Scene(p);
    pr.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());
    return pr;
}
 
Example #14
Source File: GemOverlay_Stage.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
public void loadFXMLBeta(){
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/poe/level/fx/overlay/GemOverlayBeta.fxml"));
    AnchorPane ap = null;
    try {
        ap = loader.load();
    } catch (IOException ex) {
        Logger.getLogger(GemOverlay_Stage.class.getName()).log(Level.SEVERE, null, ex);
    }
    controller_beta = loader.<GemOverlayBeta_Controller>getController();

    Scene scene = new Scene(ap);
    scene.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());
    scene.setFill(Color.TRANSPARENT);


    this.setScene(scene);

    controller_beta.hookStage(this);
    controller_beta.defaultTitle();
    this.show();

}
 
Example #15
Source File: GameView.java    From CrazyAlpha with GNU General Public License v2.0 6 votes vote down vote up
public static Initializable getInitializable(String viewName) throws IOException {
    FXMLLoader loader = new FXMLLoader();    // 创建对象

    loader.setBuilderFactory(new JavaFXBuilderFactory());    // 设置BuilderFactory
    loader.setLocation(GameView.class.getResource(viewName + ".fxml"));    // 设置路径基准

    try {
        InputStream in = GameView.class.getResourceAsStream(viewName + ".fxml");
        AnchorPane page = (AnchorPane) loader.load(in); // 对象方法的参数是InputStream,返回值是Object

        Scene scene = new Scene(page, 800, 600);
        Stage stage = new Stage();
        stage.setScene(scene);
        stage.sizeToScene();

        return (Initializable) loader.getController();    // 可以得到Controller

    } finally {
        in.close();
        return null;
    }
}
 
Example #16
Source File: PlayfairTest.java    From charts with Apache License 2.0 5 votes vote down vote up
private Axis createRightYAxis(final double MIN, final double MAX, final boolean AUTO_SCALE) {
    Axis axis = new Axis(Orientation.VERTICAL, Position.RIGHT);
    axis.setMinValue(MIN);
    axis.setMaxValue(MAX);
    axis.setPrefWidth(AXIS_WIDTH);
    axis.setAutoScale(AUTO_SCALE);

    AnchorPane.setRightAnchor(axis, 0d);
    AnchorPane.setTopAnchor(axis, 0d);
    AnchorPane.setBottomAnchor(axis, 25d);

    return axis;
}
 
Example #17
Source File: AvailabilityEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onShowReasonEditor() {
	try {
		// display the reason editor as a dialog
		if (reasonController == null) {
			FXMLLoader loader = FXMLLoaderFactory.reasonEditorLoader();
			AnchorPane page = (AnchorPane) loader.getRoot();

			// Create the dialog Stage.
			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle(DesignerLocalizer.instance().getLangString("reason.editor"));
			dialogStage.initModality(Modality.APPLICATION_MODAL);
			Scene scene = new Scene(page);
			dialogStage.setScene(scene);

			// get the controller
			reasonController = loader.getController();
			reasonController.setDialogStage(dialogStage);
			reasonController.initialize(null);
		}

		// Show the dialog and wait until the user closes it
		reasonController.getDialogStage().showAndWait();

		Reason reason = reasonController.getSelectedReason();

		if (reason != null) {
			availabilityEvent.setReason(reason);
			availabilityEvent.setInputValue(reason.getName());
			displayReason();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example #18
Source File: LineChartTest.java    From charts with Apache License 2.0 5 votes vote down vote up
private Axis createCenterXAxis(final double MIN, final double MAX, final boolean AUTO_SCALE, final double AXIS_WIDTH) {
    Axis axis = new Axis(Orientation.HORIZONTAL, Position.CENTER);
    axis.setMinValue(MIN);
    axis.setMaxValue(MAX);
    axis.setPrefHeight(AXIS_WIDTH);
    axis.setAutoScale(AUTO_SCALE);

    AnchorPane.setBottomAnchor(axis, axis.getZeroPosition());
    AnchorPane.setLeftAnchor(axis, AXIS_WIDTH);
    AnchorPane.setRightAnchor(axis, AXIS_WIDTH);

    return axis;
}
 
Example #19
Source File: PrintStaffsController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void Back() {
    try {
        AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
        root.getChildren().setAll(studentMgmt);
    }catch(IOException e){
        System.out.println(e);
    }
}
 
Example #20
Source File: RegisterStaffController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void Back(ActionEvent event) {
    try {
        AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
        root.getChildren().setAll(studentMgmt);
    }catch(IOException e){
        System.out.println(e);
    }
}
 
Example #21
Source File: InfoInputTextField.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public void setIconsRightAligned() {
    AnchorPane.clearConstraints(infoIcon);
    AnchorPane.clearConstraints(warningIcon);
    AnchorPane.clearConstraints(privacyIcon);
    AnchorPane.clearConstraints(inputTextField);

    AnchorPane.setRightAnchor(infoIcon, 7.0);
    AnchorPane.setRightAnchor(warningIcon, 7.0);
    AnchorPane.setRightAnchor(privacyIcon, 7.0);
    AnchorPane.setLeftAnchor(inputTextField, 0.0);
    AnchorPane.setRightAnchor(inputTextField, 0.0);
}
 
Example #22
Source File: WorkScheduleEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onViewShifts() {
	try {
		if (getSelectedSchedule() == null) {
			throw new Exception(DesignerLocalizer.instance().getErrorString("choose.schedule"));
		}

		if (shiftsController == null) {
			FXMLLoader loader = FXMLLoaderFactory.scheduleShiftsLoader();
			AnchorPane page = (AnchorPane) loader.getRoot();

			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle("Work Schedule Shift Instances");
			dialogStage.initModality(Modality.NONE);
			Scene scene = new Scene(page);
			dialogStage.setScene(scene);

			// get the controller
			shiftsController = loader.getController();
			shiftsController.setDialogStage(dialogStage);
			shiftsController.initializeApp(getApp());
		}

		shiftsController.setCurrentSchedule(getSelectedSchedule());

		if (!shiftsController.getDialogStage().isShowing()) {
			shiftsController.getDialogStage().showAndWait();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example #23
Source File: LogAxisTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    AnchorPane pane = new AnchorPane(xAxisBottom, yAxisLeft);
    pane.setPadding(new Insets(10));
    pane.setPrefSize(400, 400);

    Scene scene = new Scene(pane);

    stage.setTitle("Title");
    stage.setScene(scene);
    stage.show();
}
 
Example #24
Source File: GemOverlay_Controller.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
public void addGem(Gem add, Gem socketgroup){
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/poe/level/fx/overlay/add_gem_overlay.fxml"));
    AnchorPane ap = null;
    try {
        ap = loader.load();
    } catch (IOException ex) {
        Logger.getLogger(GemOverlay_Controller.class.getName()).log(Level.SEVERE, null, ex);
    }
    loader.<Add_gem_overlay_Controller>getController().load(add,socketgroup);
    gem_overlay_container.getChildren().add(ap);
}
 
Example #25
Source File: AbstractFXMLComponent.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
private void initComponent(String fxmlResource, String resourceBundle) {
	// init rest
	if (fxmlResource == null || fxmlResource.isEmpty()) {
		this.fxmlResource = getClass().getName() + ".fxml";
	} else {
		this.fxmlResource = fxmlResource;
	}
	this.resourceBundle = resourceBundle;
	if (this.resourceBundle == null) {
		this.resourceBundle = DEFAULT_BUNDLE;
	}
	// initUI
	Locale userLocale = Locale.ENGLISH; // TODO i18n
	try {
		ui = FXMLLoader.load(getClass().getResource(this.fxmlResource),
				ResourceBundle.getBundle(this.resourceBundle, userLocale));
		this.getChildren().add(ui);
		AnchorPane.setBottomAnchor(ui, 0d);
		AnchorPane.setTopAnchor(ui, 0d);
		AnchorPane.setLeftAnchor(ui, 0d);
		AnchorPane.setRightAnchor(ui, 0d);
	} catch (IOException e) {
           e.printStackTrace();
		throw new IllegalArgumentException("Failed to load component: "
				+ this, e);
	}
}
 
Example #26
Source File: GemOverlay_Controller.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
public void socketGroupReplace(Gem add, Gem remove){
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/poe/level/fx/overlay/replace_socket_group_overlay.fxml"));
    AnchorPane ap = null;
    try {
        ap = loader.load();
    } catch (IOException ex) {
        Logger.getLogger(GemOverlay_Controller.class.getName()).log(Level.SEVERE, null, ex);
    }
    loader.<Replace_socket_group_overlay_Controller>getController().load(add,remove);
    gem_overlay_container.getChildren().add(ap);

}
 
Example #27
Source File: LineChartTest.java    From charts with Apache License 2.0 5 votes vote down vote up
private Axis createCenterYAxis(final double MIN, final double MAX, final boolean AUTO_SCALE, final double AXIS_WIDTH) {
    Axis axis = new Axis(Orientation.VERTICAL, Position.CENTER);
    axis.setMinValue(MIN);
    axis.setMaxValue(MAX);
    axis.setPrefWidth(AXIS_WIDTH);
    axis.setAutoScale(AUTO_SCALE);

    AnchorPane.setTopAnchor(axis, 0d);
    AnchorPane.setBottomAnchor(axis, AXIS_WIDTH);
    AnchorPane.setLeftAnchor(axis, axis.getZeroPosition());

    return axis;
}
 
Example #28
Source File: AbstractExamplePane.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
public final void setExampleCode(String code) {
	SamplePage samplePage = new SamplePage(code);
	codePane.getChildren().setAll(samplePage);
	AnchorPane.setBottomAnchor(samplePage, 5d);
	AnchorPane.setTopAnchor(samplePage, 5d);
	AnchorPane.setLeftAnchor(samplePage, 5d);
	AnchorPane.setRightAnchor(samplePage, 5d);
}
 
Example #29
Source File: ScrollBarPane.java    From JavaFX with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	AnchorPane pane = new AnchorPane();
	Scene frame = new Scene(pane, 300, 300);
	primaryStage.setScene(frame);

	TextArea ta = new TextArea("fdsgthtyjyt");
	ta.setMaxSize(150, 150);
	ta.setWrapText(true);
	pane.getChildren().addAll(ta);
	
	primaryStage.show();


}
 
Example #30
Source File: CharacterInfo_Controller.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
@FXML
public void buildPopup() {
    btnSelectCharacter.setDisable(true);
    btnAutoStart.setDisable(true);
    FXMLLoader loader = new FXMLLoader(getClass().getResource("SelectCharacter_Popup.fxml"));
    try {
        ArrayList<CharacterInfo> characters = POEAPIHelper.getCharacters(txtAccountName.getText());
        if (characters == null || characters.isEmpty()) {
            lblAutoError.setVisible(true);
            lblAutoError.setText("Failed to get your characters");
            return;
        } else {
            lblAutoError.setVisible(false);
        }
        loader.setController(new SelectCharacter_PopupController(characters));
        AnchorPane con = loader.load();
        SelectCharacter_PopupController controller = loader.getController();
        controller.hook(this::closePopup);
        addBuildPopup = new JFXDialog(root.getRootPane(), con, JFXDialog.DialogTransition.CENTER);
        addBuildPopup.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());
        //controller.passDialog(mLoad);
        addBuildPopup.show();
        addBuildPopup.setOnDialogClosed(event -> btnSelectCharacter.setDisable(false));
    } catch (IOException ex) {
        Logger.getLogger(MainApp_Controller.class.getName()).log(Level.SEVERE, null, ex);
        btnSelectCharacter.setDisable(false);
    }
}