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

The following examples show how to use javafx.fxml.FXMLLoader#setRoot() . 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: PharmacistController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param username
 */
public PharmacistController(String username) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/Pharmacist.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    
    pharmacist = new Pharmacist(username);
    this.username = username;
    pharmacist.saveLogin(username);

    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 2
Source File: ServiceViewer.java    From diirt with MIT License 6 votes vote down vote up
public ServiceViewer() {
    FXMLLoader fxmlLoader = new FXMLLoader(
            getClass().getResource("ServiceViewer.fxml"));

    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

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

    TreeItem<BrowserItem> root = new TreeBrowserItem(new ServiceRootBrowserItem());
    root.setExpanded(true);
    servicesTreeTable.setRoot(root);
    servicesTreeTable.setShowRoot(false);
    servicesTreeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
    TreeTableColumn<BrowserItem,String> nameCol = new TreeTableColumn<>("Name");
    TreeTableColumn<BrowserItem,String> descriptionCol = new TreeTableColumn<>("Description");

    servicesTreeTable.getColumns().setAll(nameCol, descriptionCol);

    nameCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
    descriptionCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("description"));
}
 
Example 3
Source File: DragIcon.java    From java_fx_node_link_demo with The Unlicense 6 votes vote down vote up
public DragIcon() {
	
	FXMLLoader fxmlLoader = new FXMLLoader(
			getClass().getResource("/DragIcon.fxml")
			);
	
	fxmlLoader.setRoot(this); 
	fxmlLoader.setController(this);
	
	try { 
		fxmlLoader.load();
       
	} catch (IOException exception) {
	    throw new RuntimeException(exception);
	}
}
 
Example 4
Source File: PCGenStatusBar.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public PCGenStatusBar()
{
	try
	{
		FXMLLoader loader = new FXMLLoader();
		loader.setResources(LanguageBundle.getBundle());
		loader.setController(this);
		loader.setRoot(this);
		loader.setLocation(getClass().getResource("PCGenStatusBar.fxml"));
		loader.load();
	}
	catch (IOException e)
	{
		throw new IORuntimeException(e);
	}
}
 
Example 5
Source File: FleetTabShipPopup.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 艦隊タブポップアップのコンストラクタ
 *
 * @param chara キャラクター
 */
public FleetTabShipPopup(Chara chara) {
    this.chara = chara;
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/fleet_tab_popup.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 6
Source File: QuestPane.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 任務のコンストラクタ
 *
 * @param quest 任務
 */
public QuestPane(AppQuest quest) {
    this.quest = quest;
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/quest.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 7
Source File: StatisticsPane.java    From logbook-kai with MIT License 5 votes vote down vote up
public StatisticsPane() {
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/statistics.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 8
Source File: LoadingBoardView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public LoadingBoardView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/LoadingBoardView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

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

	loadingIndicator.setProgress(-1);
}
 
Example 9
Source File: DeviceView.java    From ClusterDeviceControlPlatform with MIT License 5 votes vote down vote up
private void loadFxml() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("device_view.fxml"));
    loader.setRoot(this);
    loader.setController(this);
    try {
        loader.load();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 10
Source File: PopupSelectboxContainer.java    From logbook-kai with MIT License 5 votes vote down vote up
PopupSelectboxContainer() {
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/popup-selectbox.fxml");
        loader.setRoot(this);
        loader.setController(this);
        InternalFXMLLoader.setGlobal(loader.load());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: HMDPostEditorControl.java    From Lipi with MIT License 5 votes vote down vote up
private void bindFxml() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("HMDPostEditor.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
        fxmlLoader.load();
    } catch (IOException e) {
        System.out.println("Failed to load fxml");
        ExceptionAlerter.showException(e);
        throw new RuntimeException(e);
    }
}
 
Example 12
Source File: Initialization.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
public static void initializeFXML(Object object, String resourceName) {
    FXMLLoader fxmlLoader = new FXMLLoader(
            object.getClass().getResource(resourceName)
    );
    fxmlLoader.setRoot(object);
    fxmlLoader.setController(object);
    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example 13
Source File: AboutDialog.java    From javafx-TKMapEditor with GNU General Public License v3.0 5 votes vote down vote up
private AboutDialog() {
	FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("AboutDialog.fxml"));
	fXMLLoader.setRoot(AboutDialog.this);
	fXMLLoader.setController(AboutDialog.this);
	try {
		fXMLLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}
}
 
Example 14
Source File: FileTreeTable.java    From Lipi with MIT License 5 votes vote down vote up
private void bindFxml() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("file_tree_table.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
        fxmlLoader.load();
    } catch (IOException e) {
        System.out.println("Failed to load fxml" + e.getMessage());
        ExceptionAlerter.showException(e);
        throw new RuntimeException(e);
    }

    this.getStyleClass().add("file-tree-table");
}
 
Example 15
Source File: CardEntry.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public CardEntry() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/CardEntry.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

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

	setCache(true);
}
 
Example 16
Source File: BattleLogController.java    From logbook-kai with MIT License 5 votes vote down vote up
public UnitDialog() {
    try {
        FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/battlelog_dialog.fxml");
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
    } catch (IOException e) {
        LoggerHolder.get().error("FXMLのロードに失敗しました", e);
    }
}
 
Example 17
Source File: HttpRoundTripMessagePane.java    From cute-proxy with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public HttpRoundTripMessagePane() throws IOException {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/http_round_trip_message.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    fxmlLoader.load();
}
 
Example 18
Source File: OverlayModal.java    From youtube-comment-suite with MIT License 4 votes vote down vote up
public OverlayModal() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("OverlayModal.fxml"));
    loader.setController(this);
    loader.setRoot(this);
    loader.load();
}
 
Example 19
Source File: CsvSettingsManager.java    From TAcharting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public CsvSettingsManager(){
    Dialog<Boolean> settingsDialog = new Dialog<>();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(("fxml/charting-CsvSettings.fxml")));
    fxmlLoader.setController(this);
    fxmlLoader.setRoot(rootPane);
    rootPane.getStylesheets().add("fxml/charting-Settings.css");
    settingsDialog.getDialogPane().setContent(rootPane);
    try{
        fxmlLoader.load();
        CsvProperties csvProperties = new CsvProperties();
        stringQuoteBox.setItems(FXCollections.observableArrayList("\"", "\'"));
        stringQuoteBox.valueProperty().bindBidirectional(csvProperties.quoteProperty());
        seperatorBox.valueProperty().bindBidirectional(csvProperties.separatorProperty());
        seperatorBox.setItems(FXCollections.observableArrayList(",", " ", ";"));

        ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
        ButtonType cancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
        settingsDialog.getDialogPane().getButtonTypes().addAll(save,cancel);
        settingsDialog.setResultConverter(button ->{
            if(button == save){
                csvProperties.save();
                return true;
            }
            return false;
        });

        colTimeFormatID.setCellValueFactory(new PropertyValueFactory<>("id"));
        colTimeFormat.setCellValueFactory(new PropertyValueFactory<>("TimeFormat"));
        colComment.setCellValueFactory(new PropertyValueFactory<>("Comment"));
        colExample.setCellValueFactory(new PropertyValueFactory<>("Example"));

        Callback<TableColumn<ExampleRow, String>, TableCell<ExampleRow,String>> cellFactory =
                new Callback<TableColumn<ExampleRow, String>, TableCell<ExampleRow, String>>() {
            @Override
            public TableCell<ExampleRow, String> call(TableColumn<ExampleRow, String> param) {
                final TableCell<ExampleRow, String> cell = new TableCell<ExampleRow, String>(){
                    final Button btn = new Button("Show Example");
                    @Override
                    public void updateItem(String string, boolean empty){
                        super.updateItem(string,empty);
                        if(empty){
                            setGraphic(null);
                            setText(null);
                        } else {
                            btn.setOnAction(event -> {
                                ExampleRow row = tblExample.getItems().get(getIndex());
                                int id = row.getId();
                                String path = null;
                                if(id == TimeFormatType.yyyy_MM_ddHmsz.id){
                                    path = getClass().getClassLoader().getResource("aapl_hourly.csv").getPath();
                                } else if(id == TimeFormatType.yyyyMMdd.id){
                                    path = getClass().getClassLoader().getResource("aapl_daily.csv").getPath();
                                } else if(id == TimeFormatType.YAHOO.id){
                                    path = getClass().getClassLoader().getResource("example3.csv").getPath();
                                } else if (id == TimeFormatType.EODATA.id){
                                    path = getClass().getClassLoader().getResource("AAAP_daily_eodata.csv").getPath();
                                }
                                try {
                                    if(Parameter.OS.contains("win")){
                                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler"  + path);
                                    } else if(Parameter.OS.contains("nix")||Parameter.OS.contains("nux")){
                                        Runtime.getRuntime().exec("xdg-open " + path);
                                    }
                                    else{
                                        final String path2 = path;
                                        Platform.runLater(() ->
                                                new Alert(Alert.AlertType.INFORMATION,
                                                "No editor found for your System. Inspect file: "+path2).show());
                                    }

                                } catch (IOException | NullPointerException e){
                                    e.printStackTrace();
                                    new Alert(Alert.AlertType.INFORMATION,
                                            "No editor found. Inspect file: " + path).show();
                                }
                            });
                            setGraphic(btn);
                            setText(null);
                        }
                    }
                };
                return cell;
            }
        };
        colExample.setCellFactory(cellFactory);


        for(TimeFormatType tt: TimeFormatType.values()){
            tblExample.getItems().add(new ExampleRow(tt));
        }

        settingsDialog.showAndWait();

    } catch (IOException ioe){
        ioe.printStackTrace();
    }
}
 
Example 20
Source File: EditorMainWindow.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
public EditorMainWindow() {

		FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/EditorMainWindow.fxml"));
		fxmlLoader.setRoot(this);
		fxmlLoader.setController(this);

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

		minionRadioButton.setToggleGroup(cardTypeGroup);
		spellRadioButton.setToggleGroup(cardTypeGroup);
		weaponRadioButton.setToggleGroup(cardTypeGroup);
		minionRadioButton.setSelected(true);

		minionRadioButton.setOnAction(event -> setCardEditor(new MinionCardPanel()));
		spellRadioButton.setOnAction(event -> setCardEditor(new SpellCardPanel()));

		nameField.textProperty().addListener(this::onNameChanged);
		descriptionField.textProperty().addListener(this::onDescriptionChanged);

		rarityBox.setItems(FXCollections.observableArrayList(Rarity.values()));
		heroClassBox.setItems(FXCollections.observableArrayList(HeroClass.values()));
		cardSetBox.setItems(FXCollections.observableArrayList(CardSet.values()));

		setCardEditor(new MinionCardPanel());

		rarityBox.valueProperty().addListener(this::onRarityChanged);
		resetButton.setOnAction(this::reset);
		saveButton.setOnAction(this::onSaveButton);
		heroClassBox.valueProperty().addListener(this::onHeroClassChanged);
		cardSetBox.valueProperty().addListener(this::onCardSetChanged);
		collectibleBox.setOnAction(this::onCollectibleChanged);
		manaCostField.textProperty().addListener(new IntegerListener(value -> card.baseManaCost = value));

		attributeBoxes = new ArrayList<>();
		attributeFields = new ArrayList<>();
		for (int i = 1; i < 99; i++) {
			@SuppressWarnings("unchecked")
			ComboBox<Attribute> box = (ComboBox<Attribute>) lookup("#attributeBox" + i);
			if (box == null) {
				break;
			}
			TextField field = (TextField) lookup("#attributeField" + i);
			attributeBoxes.add(box);
			attributeFields.add(field);
		}
		setupAttributeBoxes();
	}