Java Code Examples for javafx.fxml.FXMLLoader#setController()

The following examples show how to use javafx.fxml.FXMLLoader#setController() . 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: RootLayout.java    From java_fx_node_link_demo with The Unlicense 7 votes vote down vote up
public RootLayout() {
	
	FXMLLoader fxmlLoader = new FXMLLoader(
			getClass().getResource("/RootLayout.fxml")
			);
	
	fxmlLoader.setRoot(this); 
	fxmlLoader.setController(this);
	
	try { 
		fxmlLoader.load();
       
	} catch (IOException exception) {
	    throw new RuntimeException(exception);
	}
}
 
Example 2
Source File: UserDialog.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public UserDialog(String title, String message, DialogType dialogType) {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/UserDialog.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	icon.setImage(IconFactory.getDialogIcon(dialogType));
	headerLabel.setText(title);
	textLabel.setText(message);

	positiveButton.setOnAction(this);
	negativeButton.setOnAction(this);
}
 
Example 3
Source File: FindTextWidget.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void start(Stage primaryStage) throws Exception {
	this.primaryStage = primaryStage;
	FXMLLoader loader = AssetFactory.loadLayout("layout/findWidget.fxml", true);
	Parent root;
	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();

	Platform.runLater(() -> {
		primaryStage.setTitle("Find/Replace");
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		// primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 4
Source File: PlayModeConfigView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public PlayModeConfigView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/PlayModeConfigView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	formatBox.setConverter(new DeckFormatStringConverter());

	player1Config = new PlayerConfigView(PlayerConfigType.HUMAN);
	player2Config = new PlayerConfigView(PlayerConfigType.OPPONENT);

	playerArea.getChildren().add(player1Config);
	playerArea.getChildren().add(player2Config);

	startButton.setOnAction(this);
	backButton.setOnAction(this);

	formatBox.valueProperty().addListener((ChangeListener<DeckFormat>) (observableProperty, oldDeckFormat, newDeckFormat) -> {
		setDeckFormats(newDeckFormat);
	});
}
 
Example 5
Source File: ToolboxView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public ToolboxView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/ToolboxView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	playerPanel = new PlayerPanel();
	getItems().add(playerPanel);
	getItems().add(new Separator());
	cardPanel = new CardPanel();
	getItems().add(cardPanel);
	getItems().add(new Separator());
	minionPanel = new MinionPanel();
	getItems().add(minionPanel);
}
 
Example 6
Source File: MessageDisplay.java    From xltsearch with Apache License 2.0 6 votes vote down vote up
MessageDisplay() {
    stage.setTitle("Messages");
    stage.getIcons().addAll(new Image(getClass().getResourceAsStream("/icon32.png")),
                            new Image(getClass().getResourceAsStream("/icon22.png")),
                            new Image(getClass().getResourceAsStream("/icon16.png")));
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/message_display.fxml"));
    fxmlLoader.setController(this);
    try {
        Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
        stage.setScene(scene);
    } catch (Exception ex) {
        DetailedAlert alert = new DetailedAlert(DetailedAlert.AlertType.ERROR);
        alert.setTitle("Error");
        alert.setHeaderText("Exception while loading MessageDisplay");
        alert.setDetailsText(MessageLogger.getStackTrace(ex));
        alert.showAndWait();
    }
}
 
Example 7
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: SandboxEditor.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public SandboxEditor(String fxmlFile) {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/" + fxmlFile));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}
}
 
Example 9
Source File: AllMessagesController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
public AllMessagesController(User newSysUser) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/AllMessages.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    this.newSysUser = newSysUser;
    
    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 10
Source File: MGMVYouTubeObjectItem.java    From youtube-comment-suite with MIT License 5 votes vote down vote up
private void initialize() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MGMVYouTubeObjectItem.fxml"));
        loader.setController(this);
        loader.setRoot(this);
        loader.load();

        thumbnail.setImage(ImageLoader.LOADING.getImage());
        thumbnail.setCursor(Cursor.HAND);
        thumbnail.setOnMouseClicked(me -> browserUtil.open(object.buildYouTubeLink()));

        if (isVideo) {
            thumbnail.setFitWidth(89);
        } else {
            thumbnail.setFitWidth(50);
        }

        new Thread(() -> {
            Image image = ImageCache.findOrGetImage(object);

            runLater(() -> thumbnail.setImage(image));
        }).start();

        title.setText(object.getTitle());

        subtitle.setText(justSubtitle ? subtitleText :
                (commentsDisabled ? String.format("%s", subtitleSuffix) :
                        String.format("%,d %s", value, subtitleSuffix)));

        if (commentsDisabled) {
            subtitle.setStyle("-fx-text-fill:orangered");
        }
    } catch (IOException e) {
        logger.error("Failed to initialize MGMVYouTubeObjectListItem", e);
    }
}
 
Example 11
Source File: PlayerInfoView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public PlayerInfoView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/PlayerInfoView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}
}
 
Example 12
Source File: BattleDetailPhaseStage2.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
* Stage2 詳細
* @param stage2 Stage2
* @param friendName 味方の名前(僚艦/基地航空隊 等)
*/
public BattleDetailPhaseStage2(Stage2 stage2, String friendName) {
    this.stage2 = stage2;
    this.friendName = friendName;
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/battle_detail_phase_stage2.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 13
Source File: TextView.java    From neural-style-gui with GNU General Public License v3.0 5 votes vote down vote up
public TextView() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/textView.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 14
Source File: FleetTabShipPopup.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 艦隊タブポップアップのコンストラクタ
 *
 * @param chara キャラクター
 * @param slotIndex スロット番号
 */
public FleetTabShipPopupItem(Chara chara, int slotIndex) {
    this.chara = chara;
    this.slotIndex = slotIndex;
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/fleet_tab_popup_item.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 15
Source File: SecurityKeyboard.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
public SecurityKeyboard() {

        FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/adr/helloiot/fxml/securitykeyboard.fxml"));
        loader.setController(this);

        try {
            content = loader.load();
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        }
    }
 
Example 16
Source File: PreferencePane.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
public PreferencePane() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/preference/PreferencePane.fxml"), bundle);
    loader.setRoot(this);
    loader.setController(this);

    try {
        loader.load();
    }
    catch (Exception ex) {
        LOG.log(Level.SEVERE, "Unable to load FXML", ex);
    }
    getButtonTypes().addAll(ButtonType.APPLY, ButtonType.CLOSE);

    bindProperties();
}
 
Example 17
Source File: BattleDetailPhase.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
* 戦闘ログ詳細のフェーズのコンストラクタ
*
* @param phase フェイズ
* @param infomation 付加情報
* @param isFriendlyBattle 友軍艦隊フラグ
*/
public BattleDetailPhase(PhaseState phase, List<? extends Node> infomation, boolean isFriendlyBattle) {
    this.phase = new PhaseState(phase);
    this.attackDetails = new ArrayList<>(phase.getAttackDetails());
    this.nodes = infomation;
    this.isFriendlyBattle = isFriendlyBattle;
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/battle_detail_phase.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 18
Source File: PrescriptionListController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
public PrescriptionListController() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/PrescriptionListPopup.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    
    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 19
Source File: WarningController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
public WarningController() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/Warning.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    
    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 20
Source File: PasswordDialog.java    From chat-socket with MIT License 4 votes vote down vote up
PasswordPane() throws IOException {
    FXMLLoader fxmlLoader = new FXMLLoader(LayoutsResource.getInstance().getResource("password-dialog.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    fxmlLoader.load();
}