/** * Utility method to discover the {@code Paint} used by {@code Label} * * @return Base Paint use of Labels */ public static Paint getBaseTextColor() { final Label label = new Label(BASE_COLOR); final Scene scene = new Scene(new Group(label)); scene.getRoot().styleProperty().setValue(getStyleProperty().getValue()); label.applyCss(); return label.getTextFill(); }
/** Nastaví scénu. */ public ScreenBuilder setScene(Scene scene) { this.scene = scene; if (this.scene.getRoot() == null) this.scene.setRoot(root); else this.root = scene.getRoot(); return this; }
@Override public void start(Stage stage) { stage.setTitle("URL Lister"); Scene scene = new Scene(new Group(), 1250, 700); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("Server: "), 0, 0); grid.add(new Label("URL: "), 0, 1); grid.add(subject, 1, 1, 3, 1); grid.add(text, 1, 60, 2, 10); grid.add(text2, 10, 60, 2, 10); grid.add(text3, 10, 20, 2, 5); grid.add(button, 0, 3); grid.add(button2, 5, 60); grid.add(button3, 5, 65); grid.add(notification, 1, 3, 3, 1); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
/** * Initialize screenshot * * <p>Must be called on UI thread * * @param scene Scene to capture * @throws Exception on error */ public Screenshot(final Scene scene) throws Exception { image = fromNode(scene.getRoot()); // Create snapshot file // final WritableImage jfx = scene.snapshot(null); // image = new BufferedImage((int)jfx.getWidth(), // (int)jfx.getHeight(), // BufferedImage.TYPE_INT_ARGB); // SwingFXUtils.fromFXImage(jfx, image); }
@Override public void start(Stage stage) throws IOException { this.stage = stage; List<User> p = new ArrayList<User>(); User u1 = new User("alfred", "*****@*****.**"); User u2 = new User("björn", "*****@*****.**"); User u3 = new User("klaus", "*****@*****.**"); User u4 = new User("lukas", "*****@*****.**"); p.add(u1); p.add(u2); p.add(u3); p.add(u4); Experiment experiment = new Experiment(u1, new FocusQuestion("How dare you?", u1), 4, false, false); experiment.addParticipant(u1); experiment.addParticipant(u2); experiment.addParticipant(u3); experiment.addParticipant(u4); map = new ConceptMap(experiment); ConceptMapViewBuilder builder = new ConceptMapViewBuilder(); ObservableConceptFactory conceptFactory = new ObservableConceptFactory(); ConceptViewBuilder conceptBuilder = new ConceptViewBuilder(map, conceptFactory); scene = builder.withConceptViewBuilder(conceptBuilder).withConceptMap(map).build(); controller = builder.getController(); conceptMapView = (ConceptMapView) scene.getRoot(); stage.setScene(scene); stage.setFullScreen(true); stage.show(); }
@Override public void start(Stage stage) { final Parameters params = getParameters(); final List<String> parameters = params.getRaw(); if (parameters.size() != 1) { throw new RuntimeException( "Bad command line arguments, expected exactly one argument (XML file to load)"); } final String fileToLoad = parameters.get(0); final ProfileContainer profiles; try { FileInputStream in = new FileInputStream(fileToLoad); profiles = new XMLSerializer().load(in); } catch (IOException e) { throw new RuntimeException(e); } final TreeTableView<ITreeNode> treeTable = createTreeTableView(profiles); treeTable.setPrefSize(2000, 2000); stage.setTitle("Profiling results: " + fileToLoad); stage.setResizable(true); final Scene scene = new Scene(new Group(), 1000, 1000); final Group sceneRoot = (Group) scene.getRoot(); sceneRoot.setAutoSizeChildren(true); sceneRoot.getChildren().add(treeTable); stage.setScene(scene); stage.show(); }
@Override public void start(Stage stage) { stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); scene.setFill(Color.BLACK); MenuBar menuBar = new MenuBar(); // --- Menu File Menu menuFile = new Menu("File"); // --- Menu Edit Menu menuEdit = new Menu("Edit"); // --- Menu View Menu menuView = new Menu("Lagersaldo för butik"); menuBar.getMenus().addAll(menuFile, menuEdit, menuView); ((VBox) scene.getRoot()).getChildren().addAll(menuBar); stage.setScene(scene); stage.show(); }
@Override public void start(Stage stage) throws Exception { // ----------MENU---------- MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem menuItemPurchase = new MenuItem("New Purchase"); MenuItem menuItemStore = new MenuItem("New Store"); MenuItem menuItemCategory = new MenuItem("New Category"); MenuItem menuItemExit = new MenuItem("Exit"); menuFile.getItems().addAll(menuItemPurchase, menuItemStore, menuItemCategory, menuItemExit); Menu menuHelp = new Menu("Help"); menuBar.getMenus().addAll(menuFile, menuHelp); // ----------TOOLBAR---------- ToolBar toolBar = new ToolBar(); Button buttonPurchase = new Button(); Button buttonStore = new Button(); Button buttonCategory = new Button(); buttonPurchase.setGraphic(new ImageView("/pictures/purchase.png")); buttonStore.setGraphic(new ImageView("/pictures/store.png")); buttonCategory.setGraphic(new ImageView("/pictures/category.png")); toolBar.getItems().addAll(buttonPurchase, buttonStore, buttonCategory); buttonStore.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { Stage stage = new Stage(); try { new StoreWindows().start(stage); } catch (Exception e) { e.printStackTrace(); } } }); // ----------WORKSPACE---------- GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setVgap(10); gridPane.setHgap(10); gridPane.setPadding(new Insets(0, 25, 25, 0)); Label storeLabel = new Label("Store: "); storeLabel.setId("simpleLabel"); gridPane.add(storeLabel, 0, 1); final ComboBox<String> stores = new ComboBox<String>(); gridPane.add(stores, 1, 1); Label categoryLabel = new Label("Category: "); categoryLabel.setId("simpleLabel"); gridPane.add(categoryLabel, 2, 1); final ComboBox<String> categories = new ComboBox<String>(); gridPane.add(categories, 3, 1); Button bCount = new Button("Count"); HBox hBox = new HBox(10); hBox.setAlignment(Pos.BOTTOM_RIGHT); hBox.getChildren().add(bCount); gridPane.add(hBox, 4, 1); FlowPane flowPane1 = new FlowPane(); flowPane1.setAlignment(Pos.CENTER); flowPane1.setPadding(new Insets(10, 25, 25, 10)); final Text spentTitle = new Text("SPENT: "); spentTitle.setId("headline"); flowPane1.getChildren().add(spentTitle); // ----------DATABASE---------- Label statusLabel = new Label(); DaoFactory daoFactory = new MySQLDaoFactory(); try { Connection connection = daoFactory.getConnection(); statusLabel.setText("Database connection: success"); StoreDao storeDao = new MySQLStoreDao(connection); ArrayList<Store> storeList = (ArrayList) storeDao.getStores(); for (Store store : storeList) { stores.getItems().add(store.getName()); } CategoryDao categoryDao = new MySQLCategoryDao(connection); ArrayList<Category> categoryList = (ArrayList) categoryDao.getCategories(); for (Category category : categoryList) { categories.getItems().add(category.getTitle()); } } catch (SQLException e) { statusLabel.setText("Database connection: failed"); } FlowPane footer = new FlowPane(); footer.setPadding(new Insets(10, 10, 10, 10)); footer.getChildren().add(statusLabel); bCount.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { try { PurchaseDao purchaseDao = new MySQLPurchaseDao(new MySQLDaoFactory().getConnection()); spentTitle.setText( "SPENT: " + purchaseDao.showSpent(stores.getValue(), categories.getValue())); } catch (SQLException e) { e.printStackTrace(); } } }); // ----------VIEW---------- Scene scene = new Scene(new VBox(), 800, 600); scene.getStylesheets().add("css/style.css"); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, toolBar, gridPane, flowPane1, footer); stage.setScene(scene); stage.setTitle("Cash Organizer"); stage.getIcons().add(new Image("pictures/icon.png")); stage.show(); }
@Override public void start(Stage stage) { // stage.initStyle(StageStyle.UNDECORATED); stage.setTitle("Hello Image Clipboard"); Scene scene = new Scene(new Group(), 1024, 768); scene.setFill(Color.LIGHTGREEN); Rectangle overlay = new Rectangle(); overlay.setWidth(800); overlay.setHeight(600); overlay.setFill(Color.TRANSPARENT); EventHandler<DragEvent> drop = de -> checkBoard(de.getDragboard(), de); EventHandler<DragEvent> enter = de -> { if (de != null && de.getDragboard() != null && de.getDragboard().hasImage()) { de.acceptTransferModes(TransferMode.ANY); } }; EventHandler<DragEvent> dragged = de -> { if (de != null && de.getDragboard() != null && de.getDragboard().hasImage()) { de.acceptTransferModes(TransferMode.ANY); } }; overlay.setOnDragDropped(drop); overlay.setOnDragEntered(enter); overlay.setOnDragOver(dragged); clearBtn = new Button("Clear"); clearBtn.setTranslateX(50); clearBtn.setTranslateY(30); copyBtn = new Button("Copy"); copyBtn.setTranslateX(125); copyBtn.setTranslateY(30); pasteBtn = new Button("Paste"); pasteBtn.setTranslateX(200); pasteBtn.setTranslateY(30); clearBtn.setOnAction(e -> clear()); copyBtn.setOnAction( e -> { ClipboardContent content = new ClipboardContent(); content.putImage(imageView.getImage()); Clipboard.getSystemClipboard().setContent(content); }); pasteBtn.setOnAction(e -> checkBoard(Clipboard.getSystemClipboard(), null)); Group root = (Group) scene.getRoot(); root.getChildren().add(overlay); root.getChildren().add(imageView); root.getChildren().add(clearBtn); root.getChildren().add(copyBtn); root.getChildren().add(pasteBtn); stage.setScene(scene); stage.show(); }