List of usage examples for javafx.fxml FXMLLoader load
public <T> T load() throws IOException
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleSetupLayers(Event event) { try {//from www .j a va 2 s . c o m URL layersDialogFXML = getClass().getResource(LAYERS_DIALOG_FXML); FXMLLoader loader = new FXMLLoader(layersDialogFXML); Stage layersDialog = loader.load(); MsSpectrumLayersDialogController controller = loader.getController(); controller.configure(datasets, this); layersDialog.initModality(Modality.APPLICATION_MODAL); layersDialog.show(); } catch (Exception e) { e.printStackTrace(); } }
From source file:acmi.l2.clientmod.xdat.Controller.java
private Node loadScriptTabContent() { try {/*ww w .j a v a 2 s. co m*/ FXMLLoader loader = new FXMLLoader(getClass().getResource("scripting/main.fxml")); loader.setClassLoader(getClass().getClassLoader()); loader.setControllerFactory(param -> new acmi.l2.clientmod.xdat.scripting.Controller(editor)); return wrap(loader.load()); } catch (IOException e) { log.log(Level.WARNING, "Couldn't load script console", e); } return null; }
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
@FXML void initialize() { assert clearLogButton != null : "fx:id=\"clearLogButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTable != null : "fx:id=\"fundsTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert logField != null : "fx:id=\"logField\" was not injected: check your FXML file 'mainlayout.fxml'."; assert buyButton != null : "fx:id=\"buyButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert sellButton != null : "fx:id=\"sellButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert showActiveOrdersButton != null : "fx:id=\"showActiveOrdersButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableLastColumn != null : "fx:id=\"tickerTableLastColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTablePairColumn != null : "fx:id=\"tickerTablePairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTable != null : "fx:id=\"tickersTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableBuyColumn != null : "fx:id=\"tickersTableBuyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableFeeColumn != null : "fx:id=\"tickersTableFeeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableSellColumn != null : "fx:id=\"tickersTableSellColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeAmountValue != null : "fx:id=\"tradeAmountValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceCurrencyType != null : "fx:id=\"tradeCurrencyPriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeCurrencyType != null : "fx:id=\"tradeCurrencyType\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceValue != null : "fx:id=\"tradePriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert updateFundsButton != null : "fx:id=\"updateFundsButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableCurrencyColumn != null : "fx:id=\"fundsTableCurrencyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableValueColumn != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTable != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersAmountColumn != null : "fx:id=\"activeOrdersAmountColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersPairColumn != null : "fx:id=\"activeOrdersPairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersRateColumn != null : "fx:id=\"activeOrdersRateColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTimeColumn != null : "fx:id=\"activeOrdersTimeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTypeColumn != null : "fx:id=\"activeOrdersTypeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersCancelColumn != null : "fx:id=\"activeOrdersCancelColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; //Holder for all main API methods of exchange app = new App(); //Loading configs loadExchangeConfig();/*from w w w . j ava2s . com*/ //Populate choiceboxes at the trading section tradeCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradeCurrencyType.setValue(currencies.get(0)); tradePriceCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradePriceCurrencyType.setValue(currencies.get(0)); //Active Orders table activeOrdersAmountColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("amount")); activeOrdersPairColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("pair")); activeOrdersRateColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("rate")); activeOrdersTimeColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ActiveOrder, String> activeOrderStringCellDataFeatures) { ActiveOrder activeOrder = activeOrderStringCellDataFeatures.getValue(); DateFormat dateFormat = DateFormat.getDateTimeInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(activeOrder.getTimestamp() * 1000); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); activeOrdersTypeColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("type")); activeOrdersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeOrdersCancelColumn .setCellFactory(new Callback<TableColumn<ActiveOrder, Boolean>, TableCell<ActiveOrder, Boolean>>() { @Override public TableCell<ActiveOrder, Boolean> call( TableColumn<ActiveOrder, Boolean> activeOrderBooleanTableColumn) { return new ButtonCell<>(activeOrdersTable); } }); activeOrdersCancelColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<ActiveOrder, Boolean> activeOrderBooleanCellDataFeatures) { return new SimpleBooleanProperty(true); } }); //Tickers Table MenuItem showOrdersBook = new MenuItem("Show Orders Book"); MenuItem showPublicTrades = new MenuItem("Show Public Trades"); ContextMenu contextMenu = new ContextMenu(showOrdersBook, showPublicTrades); tickersTable.setItems(tickers); tickersTable.setContextMenu(contextMenu); tickersTableBuyColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("buy")); tickersTableFeeColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("fee")); tickersTableSellColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("sell")); tickersTableLastColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("last")); tickersTablePairColumn.setCellValueFactory(new PropertyValueFactory<Ticker, String>("pair")); tickersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tickersTable.setRowFactory(new Callback<TableView<Ticker>, TableRow<Ticker>>() { @Override public TableRow<Ticker> call(TableView<Ticker> tickerTableView) { return new TableRow<Ticker>() { @Override protected void updateItem(Ticker ticker, boolean b) { super.updateItem(ticker, b); if (!b) { if (tickersData.containsKey(ticker.getPair())) { if (ticker.getLast() < tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(186, 0, 0, 0.5);"); } else if (ticker.getLast() == tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(215, 193, 44, 0.5);"); } else { setStyle("-fx-control-inner-background: rgba(0, 147, 0, 0.5);"); } } } } }; } }); //Menu item to show Orders Book showOrdersBook.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_ORDERS_BOOK_LAYOUT), resources); root = (Parent) fxmlLoader.load(); OrdersBookController ordersBookController = fxmlLoader.getController(); ordersBookController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Orders Book for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Menu item to show Public Trades showPublicTrades.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_TRADES_LAYOUT), resources); root = (Parent) fxmlLoader.load(); PublicTradesController publicTradesController = fxmlLoader.getController(); publicTradesController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Public Trades for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Funds Table fundsTableCurrencyColumn.setCellValueFactory(new PropertyValueFactory<Fund, String>("currency")); fundsTableValueColumn.setCellValueFactory(new PropertyValueFactory<Fund, Double>("value")); fundsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); fundsTable.setItems(fundsData); //Task to load tickers data from server final javafx.concurrent.Service loadTickersService = new javafx.concurrent.Service() { @Override protected Task createTask() { Task<JSONObject> loadTickers = new Task<JSONObject>() { @Override protected JSONObject call() throws Exception { String[] pairsArray = new String[pairs.size()]; pairsArray = pairs.toArray(pairsArray); return App.getPairInfo(pairsArray); } }; loadTickers.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { logField.appendText(workerStateEvent.getSource().getException().getMessage() + "\r\n"); } }); loadTickers.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONObject jsonObject = (JSONObject) workerStateEvent.getSource().getValue(); //ugly hack to store old values //dump old values to tickersData //TODO think about better solution if (tickers.size() != 0) { for (Ticker x : tickers) { tickersData.put(x.getPair(), x); } } tickers.clear(); for (Iterator iterator = jsonObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); JSONObject data = jsonObject.getJSONObject(key); Ticker ticker = new Ticker(); ticker.setPair(key); ticker.setUpdated(data.optLong("updated")); ticker.setAvg(data.optDouble("avg")); ticker.setBuy(data.optDouble("buy")); ticker.setSell(data.optDouble("sell")); ticker.setHigh(data.optDouble("high")); ticker.setLast(data.optDouble("last")); ticker.setLow(data.optDouble("low")); ticker.setVol(data.optDouble("vol")); ticker.setVolCur(data.optDouble("vol_cur")); tickers.add(ticker); } } }); return loadTickers; } }; //Update tickers every 15 seconds //TODO better solution is required Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { loadTickersService.restart(); } }), new KeyFrame(Duration.seconds(15))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.playFromStart(); }
From source file:acmi.l2.clientmod.l2smr.Controller.java
private void showUmodel(final String obj, final String file) { Platform.runLater(() -> {//w w w . j a v a2 s.com try { FXMLLoader loader = new FXMLLoader(getClass().getResource("smview/smview.fxml")); loader.load(); SMView controller = loader.getController(); controller.setStaticmesh(getStaticMeshDir(), file, obj); Scene scene = new Scene(loader.getRoot()); scene.setOnKeyReleased(controller::onKeyReleased); Stage smStage = new Stage(); smStage.setScene(scene); smStage.setTitle(obj); smStage.show(); smStage.setX(Double.parseDouble(L2smr.getPrefs().get("smview.x", String.valueOf(smStage.getX())))); smStage.setY(Double.parseDouble(L2smr.getPrefs().get("smview.y", String.valueOf(smStage.getY())))); smStage.setWidth(Double .parseDouble(L2smr.getPrefs().get("smview.width", String.valueOf(smStage.getWidth())))); smStage.setHeight(Double .parseDouble(L2smr.getPrefs().get("smview.height", String.valueOf(smStage.getHeight())))); InvalidationListener listener = observable -> { L2smr.getPrefs().put("smview.x", String.valueOf(Math.round(smStage.getX()))); L2smr.getPrefs().put("smview.y", String.valueOf(Math.round(smStage.getY()))); L2smr.getPrefs().put("smview.width", String.valueOf(Math.round(smStage.getWidth()))); L2smr.getPrefs().put("smview.height", String.valueOf(Math.round(smStage.getHeight()))); }; smStage.xProperty().addListener(listener); smStage.yProperty().addListener(listener); smStage.widthProperty().addListener(listener); smStage.heightProperty().addListener(listener); } catch (IOException e) { onException("Couldn't show staticmesh", e); } }); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void showSettingsICal() { try {/*from w w w. ja va 2 s. c o m*/ final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ICalSettingsView.fxml")); final Parent root = loader.load(); final Stage stage = new Stage(); final Scene scene = new Scene(root); stage.setTitle("iCal Settings"); stage.setScene(scene); stage.setWidth(600); stage.setHeight(400); stage.show(); } catch (final IOException e) { logger.error(e.getLocalizedMessage(), e); } }
From source file:com.github.drbookings.ui.controller.MainController.java
private void showUpcomingEvents() { try {/* w ww . ja va 2 s . c o m*/ final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/UpcomingView.fxml")); final Parent root = loader.load(); final Stage stage = new Stage(); final Scene scene = new Scene(root); stage.setTitle("What's next"); stage.setScene(scene); stage.setWidth(600); stage.setHeight(400); final Stage windowStage = (Stage) node.getScene().getWindow(); stage.setX(windowStage.getX() + windowStage.getWidth() / 2 - stage.getWidth() / 2); stage.setY((windowStage.getY() + windowStage.getHeight()) / 2 - stage.getHeight() / 2); final UpcomingController c = loader.getController(); c.setManager(getManager()); stage.show(); } catch (final IOException e) { logger.error(e.getLocalizedMessage(), e); } }
From source file:com.github.drbookings.ui.controller.MainController.java
private void showAddBookingDialog(final LocalDate date, final String roomName) { try {/*from ww w.j a va 2 s. c om*/ final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/AddBookingView.fxml")); final Parent root = loader.load(); final Stage stage = new Stage(); stage.setWidth(300); stage.setHeight(600); final Scene scene = new Scene(root); stage.setTitle("Add BookingBean"); stage.setScene(scene); final AddBookingController c = loader.getController(); c.setManager(manager); c.datePickerCheckIn.setValue(date); c.comboBoxRoom.getSelectionModel().select(roomName); final Stage windowStage = (Stage) node.getScene().getWindow(); stage.initOwner(windowStage); stage.initModality(Modality.WINDOW_MODAL); stage.setX(windowStage.getX() + windowStage.getWidth() / 2 - stage.getWidth() / 2); stage.setY((windowStage.getY() + windowStage.getHeight()) / 2 - stage.getHeight() / 2); stage.show(); } catch (final IOException e) { logger.error(e.getLocalizedMessage(), e); } }
From source file:genrsa.GenRSAController.java
/** * Muestra por pantalla la informacin relativa a genRSA * @param event /*from w w w . j a v a 2s . c om*/ */ public void aboutGenRSA(ActionEvent event) { Stage stage; FXMLLoader fxmlLoader; Parent root; try { stage = new Stage(); fxmlLoader = new FXMLLoader(getClass().getResource("/About/About.fxml")); root = fxmlLoader.load(); Scene scene = new Scene(root); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(this.unitsD.getScene().getWindow()); stage.setResizable(false); stage.getIcons().add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png"))); stage.setTitle("Acerca de genRSA v2.1"); stage.setScene(scene); stage.show(); } catch (IOException ex) { //no pongo mensaje de error, porque no se puede dar el caso } }
From source file:genrsa.GenRSAController.java
/** * Mtodo usado para cargar la ventana de ataque ciclico * @param event /*from www . j a v a2 s.c o m*/ */ public void Cyclic(ActionEvent event) { FXMLLoader fxmlLoader; Parent root; try { secondStage = new Stage(); fxmlLoader = new FXMLLoader(getClass().getResource("/Cyclic/Cyclic.fxml")); root = fxmlLoader.load(); CyclicController cyclicController = fxmlLoader.<CyclicController>getController(); cyclicController.setRadix(this.radix); if (this.RSA != null) { cyclicController.getModulus().setText(this.RSA.getN().toString(this.radix).toUpperCase()); cyclicController.getExponent().setText(this.RSA.getE().toString(this.radix).toUpperCase()); } else { cyclicController.setFirstTime(false); } disableOnProgress(true); Scene scene = new Scene(root); secondStage.initModality(Modality.NONE); secondStage.getIcons() .add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png"))); secondStage.setTitle("genRSA - Ataque Cclico"); secondStage.setScene(scene); secondStage.show(); secondStage.setOnCloseRequest(closeEvent -> { cyclicController.getCyclicAtack().setIsCancelled(true); this.disableOnProgress(false); this.disableButtons(); }); } catch (IOException ex) { //no pongo mensaje de error, porque no se puede dar el caso } }