Java Code Examples for javafx.scene.layout.VBox#setAlignment()

The following examples show how to use javafx.scene.layout.VBox#setAlignment() . 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: HtmlWebView.java    From Learn-Java-12-Programming with MIT License 9 votes vote down vote up
public void start11(Stage primaryStage) {

        Text txt1 = new Text("What a beautiful music!");
        Text txt2 = new Text("If you don't hear music, turn up the volume.");

        File f = new File("src/main/resources/jb.mp3");
        Media m = new Media(f.toURI().toString());
        MediaPlayer mp = new MediaPlayer(m);
        MediaView mv = new MediaView(mp);

        VBox vb = new VBox(txt1, txt2, mv);
        vb.setSpacing(20);
        vb.setAlignment(Pos.CENTER);
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb, 350, 100);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with embedded media player");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();

        mp.play();
    }
 
Example 2
Source File: LoadingPane.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create the loading pane.
 */
public LoadingPane() {
    setAlignment(Pos.CENTER);
    VBox content = new VBox();
    content.setAlignment(Pos.CENTER);
    Text text = new Text(LabelGrabber.INSTANCE.getLabel("loading.text") + "...");
    text.setStyle(" -fx-font: bold italic 20pt \"Arial\";");
    FadeTransition textTransition = new FadeTransition(Duration.seconds(1.5), text);
    textTransition.setAutoReverse(true);
    textTransition.setFromValue(0);
    textTransition.setToValue(1);
    textTransition.setCycleCount(Transition.INDEFINITE);
    textTransition.play();
    content.getChildren().add(text);
    bar = new ProgressBar();
    content.getChildren().add(bar);
    getChildren().add(content);
    setOpacity(0);
    setStyle("-fx-background-color: #555555;");
    setVisible(false);
}
 
Example 3
Source File: VBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public VBoxSample() {
    super(400, 100);

    CheckBox cb1 = new CheckBox("Breakfast");
    CheckBox cb2 = new CheckBox("Lunch");
    CheckBox cb3 = new CheckBox("Dinner");

    VBox vboxMeals = new VBox(5);
    vboxMeals.getChildren().addAll(cb1, cb2, cb3);

    Label label = new Label("Select one or more meals:");
    VBox vboxOuter = new VBox(10);

    vboxOuter.getChildren().addAll(label, vboxMeals);
    vboxOuter.setAlignment(Pos.CENTER_LEFT);

    getChildren().add(vboxOuter);
}
 
Example 4
Source File: DataManipulationUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
public final VBox createFilterButton(){
    VBox buttonBox = new VBox();
    buttonBox.setAlignment(Pos.CENTER);
    Button filterButton = new Button("Filter");
    UIUtils.setSize(filterButton,Main.columnWidthRIGHT,24);
    filterButton.setOnAction((ActionEvent event) -> {
        if(!AppParameters.dataset.corpus.preprocessing.equals("")){
            LogUI.addLogEntry("Filtering '"+AppParameters.dataset.id+"' (stop word set(s): "+stopwordListsCheckComboBox.getCheckModel().getCheckedItems()+", time period: ["+resizeSlider.getLowValue()+";"+resizeSlider.getHighValue()+"])");
            AppParameters.timeSliceA = AppParameters.dataset.corpus.convertDayToTimeSlice(resizeSlider.getLowValue());
            if(resizeSlider.getHighValue() != AppParameters.dataset.corpus.getLength())
                AppParameters.timeSliceB = AppParameters.dataset.corpus.convertDayToTimeSlice(resizeSlider.getHighValue());
            AppParameters.updateStopwords(stopwordListsCheckComboBox.getCheckModel().getCheckedItems());
            LogUI.addLogEntry("Done.");
        }else{
            LogUI.addLogEntry("Error: no dataset loaded");
        }
    });
    buttonBox.getChildren().addAll(filterButton);
    return buttonBox;
}
 
Example 5
Source File: ManagerEdit1.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
public void display(final Stage primaryStage, final gui.manager.WindowEnum none, final ArrayList<AbstractWindow> prevWindows) {
	window.setTitle("ManagerEdit1");
	window.setWidth(400);
	window.setHeight(100);
	final VBox vbox = new VBox(8);
	vbox.setPadding(new Insets(10, 10, 10, 10));
	vbox.setAlignment(Pos.CENTER);
	final Scene scene = new Scene(vbox);

	final Button editButton = new Button("View & Edit");
	editButton.setOnAction(λ -> {

	});
	vbox.getChildren().add(editButton);
	// scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.show();

}
 
Example 6
Source File: DotRecordBasedJavaFxNode.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private Pane fxElementFromString(final String string) {
	final VBox textContainer = new VBox();
	textContainer.setAlignment(Pos.CENTER);
	makeLines(string).forEach(line -> textContainer.getChildren()
			.add(line.getFxElement(style)));
	return textContainer;
}
 
Example 7
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private VBox getTradeFeeFieldsBox() {
    tradeFeeInBtcLabel = new Label();
    tradeFeeInBtcLabel.setMouseTransparent(true);
    tradeFeeInBtcLabel.setId("trade-fee-textfield");

    tradeFeeInBsqLabel = new Label();
    tradeFeeInBsqLabel.setMouseTransparent(true);
    tradeFeeInBsqLabel.setId("trade-fee-textfield");

    VBox vBox = new VBox();
    vBox.setSpacing(6);
    vBox.setMaxWidth(300);
    vBox.setAlignment(DevEnv.isDaoActivated() ? Pos.CENTER_RIGHT : Pos.CENTER_LEFT);
    vBox.getChildren().addAll(tradeFeeInBtcLabel, tradeFeeInBsqLabel);

    tradeFeeInBtcToggle = new AutoTooltipSlideToggleButton();
    tradeFeeInBtcToggle.setText("BTC");
    tradeFeeInBtcToggle.setPadding(new Insets(-8, 5, -10, 5));

    tradeFeeInBsqToggle = new AutoTooltipSlideToggleButton();
    tradeFeeInBsqToggle.setText("BSQ");
    tradeFeeInBsqToggle.setPadding(new Insets(-9, 5, -9, 5));

    VBox tradeFeeToggleButtonBox = new VBox();
    tradeFeeToggleButtonBox.getChildren().addAll(tradeFeeInBtcToggle, tradeFeeInBsqToggle);

    HBox hBox = new HBox();
    hBox.getChildren().addAll(vBox, tradeFeeToggleButtonBox);
    hBox.setMinHeight(47);
    hBox.setMaxHeight(hBox.getMinHeight());
    HBox.setHgrow(vBox, Priority.ALWAYS);
    HBox.setHgrow(tradeFeeToggleButtonBox, Priority.NEVER);

    final Tuple2<Label, VBox> tradeInputBox = getTradeInputBox(hBox, Res.get("createOffer.tradeFee.descriptionBSQEnabled"));

    tradeFeeDescriptionLabel = tradeInputBox.first;

    return tradeInputBox.second;
}
 
Example 8
Source File: TimeZoneEditorFactory.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final VBox controls = new VBox();
    controls.setSpacing(CONTROLS_DEFAULT_VERTICAL_SPACING);
    controls.setAlignment(Pos.CENTER);

    final ObservableList<ZoneId> timeZones = FXCollections.observableArrayList();
    ZoneId.getAvailableZoneIds().forEach(id -> {
        timeZones.add(ZoneId.of(id));
    });
    timeZoneComboBox = new ComboBox<>();
    timeZoneComboBox.setItems(timeZones.sorted(zoneIdComparator));
    final Callback<ListView<ZoneId>, ListCell<ZoneId>> cellFactory = (final ListView<ZoneId> p) -> new ListCell<ZoneId>() {
        @Override
        protected void updateItem(final ZoneId item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(TimeZoneUtilities.getTimeZoneAsString(item));
            }
        }
    };
    timeZoneComboBox.setCellFactory(cellFactory);
    timeZoneComboBox.setButtonCell(cellFactory.call(null));
    timeZoneComboBox.getSelectionModel().select(TimeZone.getTimeZone(ZoneOffset.UTC).toZoneId());
    timeZoneComboBox.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    controls.getChildren().addAll(timeZoneComboBox);
    return controls;
}
 
Example 9
Source File: Carousel.java    From DashboardFx with GNU General Public License v3.0 5 votes vote down vote up
private ObservableList<Node> createItems(){

        Label lb1 = new Label("First");
        Label lb2 = new Label("Second");
        Label lb3 = new Label("Third");
        Label lb4 = new Label("Fourth");
        Label lb5 = new Label("Fifth");

        lb1.setStyle("-fx-text-fill : white;");
        lb2.setStyle("-fx-text-fill : white;");
        lb3.setStyle("-fx-text-fill : white;");
        lb4.setStyle("-fx-text-fill : white;");
        lb5.setStyle("-fx-text-fill : white;");

        VBox v1 = new VBox(lb1);
        VBox v2 = new VBox(lb2);
        VBox v3 = new VBox(lb3);
        VBox v4 = new VBox(lb4);
        VBox v5 = new VBox(lb5);

        v1.setAlignment(Pos.CENTER);
        v2.setAlignment(Pos.CENTER);
        v3.setAlignment(Pos.CENTER);
        v4.setAlignment(Pos.CENTER);
        v5.setAlignment(Pos.CENTER);

        v1.setStyle("-fx-background-color : #FF3547;");
        v2.setStyle("-fx-background-color : #512DA8;");
        v3.setStyle("-fx-background-color : #48CFAD;");
        v4.setStyle("-fx-background-color : #02C852;");
        v5.setStyle("-fx-background-color : #EC407A;");

        return FXCollections.observableArrayList(v1, v2, v3, v4, v5);
    }
 
Example 10
Source File: NotificationsController.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventListener
public void onUpdateAvailable(UpdateAvailableEvent event) {
    VBox content = new VBox(3,
            buildLabel(DefaultI18nContext.getInstance().i18n("PDFsam {0} is available for download",
                    event.availableVersion), NotificationType.INFO),
            styledUrlButton(DefaultI18nContext.getInstance().i18n("Download"),
                    pdfsam.property(ConfigurableProperty.DOWNLOAD_URL), null));
    content.setAlignment(Pos.TOP_RIGHT);

    container.addStickyNotification(DefaultI18nContext.getInstance().i18n("New version available"), content);
}
 
Example 11
Source File: About.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
public void display(final Stage primaryStage, final WindowEnum __, final Button buttonMute) {
	window = primaryStage;
	window.setTitle("About");
	window.setWidth(1350);
	window.setHeight(450);
	final Label label = new Label(TEXT);
	label.setAlignment(Pos.CENTER);
	label.setGraphic(new ImageView(new Image(IMAGE)));
	label.setStyle("-fx-background-color: white;\n" + "-fx-text-fill: black;\n" + "-fx-background-radius: 10px;\n"
			+ "-fx-padding: 10px;\n" + "-fx-graphic-text-gap: 10px;\n" + "-fx-font-family: 'Arial';\n"
			+ "-fx-font-size: 18px;");
	final VBox vbox = new VBox(10);
	vbox.setStyle("-fx-background-color: null; -fx-padding: 10px;");
	// System.out.println("HERE IS BUTTONMUTE: "+ buttonMute.toString());

	if (!isLinuxOS) {
		final Button AboutMute = StaticMethods.cloneButton(buttonMute);
		muteButtonsAL.add(AboutMute);
		vbox.getChildren().add(AboutMute);
	}

	final Button backButton = new Button();
	backButton.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("back_button.png"))));
	backButton.getStyleClass().add("button-go");
	backButton.setOnAction(λ -> {
		window.close();
		// if (!isLinuxOS)
		// StaticMethods.dealWithMute(mediaPlayer, buttonMute, true);
		prevWindows.get(prevWindows.size() - 1).window.show();
		prevWindows.remove(prevWindows.size() - 1);
	});
	vbox.getChildren().addAll(label, backButton);
	vbox.setAlignment(Pos.CENTER);
	final Scene scene = new Scene(vbox);
	window.setScene(scene);
	scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.show();
}
 
Example 12
Source File: BasicView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public BasicView() {
    
    Label label = new Label("CloudLink Media displayed below");
    VBox controls = new VBox(15.0, label);
    controls.setAlignment(Pos.CENTER);
    
    setCenter(controls);
}
 
Example 13
Source File: Exercise_15_01.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a VBox 
	VBox vBox = new VBox();
	vBox.setAlignment(Pos.CENTER);
	vBox.setPadding(new Insets(5, 5, 5, 5));

	// Create a HBox
	HBox hBox = new HBox(5);
	hBox.setAlignment(Pos.CENTER);
	hBox.setPadding(new Insets(5, 5, 5, 5));
	getCards(hBox);

	// Create a button
	Button btRefresh = new Button("Refresh");

	// Process events
	btRefresh.setOnAction(e -> getCards(hBox));

	// Place nodes in vbox
	vBox.getChildren().addAll(hBox, btRefresh);

	// Create a scene and place it in the stage
	Scene scene = new Scene(vBox);
	primaryStage.setTitle("Exercise_15_01"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 14
Source File: ThemeStage.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(750);
	this.setHeight(540);
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setCenter(rootPane);
	this.setTitle("外观设置");

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	rootPane.setTop(topBox);
	rootPane.setCenter(borderPane);
	rootPane.setBottom(bottomBox);

	scrollPane.setBackground(Background.EMPTY);
	scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
	scrollPane.setContent(pane);
	scrollPane.widthProperty().addListener((Observable observable) -> {
		pane.setMinWidth(scrollPane.getWidth());
	});

	borderPane.setCenter(scrollPane);

	Tooltip tooltip = new Tooltip("背景覆盖颜色");
	colorPicker.setTooltip(tooltip);

	VBox vBox = new VBox();
	vBox.setAlignment(Pos.CENTER);
	vBox.getChildren().add(slider);
	slider.setTooltip(new Tooltip("背景覆盖颜色透明度"));

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(vBox);
	bottomBox.getChildren().add(colorPicker);
	bottomBox.getChildren().add(cancelButton);
	bottomBox.getChildren().add(button);
}
 
Example 15
Source File: ColorTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    gradientLookup = new GradientLookup();

    if (tile.getSections().isEmpty()) {
        tile.setSections(new Section(0.00, 0.25, ColorSkin.GREEN),
                         new Section(0.25, 0.50, ColorSkin.YELLOW),
                         new Section(0.50, 0.75, ColorSkin.ORANGE),
                         new Section(0.75, 1.00, ColorSkin.RED));
    }
    tile.setBackgroundColor(tile.getSections().get(0).getColor());

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
    valueText.setFill(tile.getValueColor());
    valueText.setTextOrigin(VPos.BASELINE);
    Helper.enableNode(valueText, tile.isValueVisible());

    upperUnitText = new Text("");
    upperUnitText.setFill(tile.getUnitColor());
    Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty());

    fractionLine = new Line();

    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());

    unitFlow = new VBox(upperUnitText, unitText);
    unitFlow.setAlignment(Pos.CENTER_RIGHT);

    valueUnitFlow = new HBox(valueText, unitFlow);
    valueUnitFlow.setAlignment(Pos.CENTER);
    valueUnitFlow.setMouseTransparent(true);

    barBackground = new Rectangle();
    barBackground.setFill(tile.getBarBackgroundColor());

    bar = new Rectangle();
    bar.setFill(tile.getForegroundColor());

    getPane().getChildren().addAll(titleText, valueUnitFlow, fractionLine, barBackground, bar);
}
 
Example 16
Source File: AttributeEditorDialog.java    From constellation with Apache License 2.0 4 votes vote down vote up
public AttributeEditorDialog(final boolean restoreDefaultButton, final AbstractEditor<?> editor) {
    final VBox root = new VBox();
    root.setPadding(new Insets(10));
    root.setAlignment(Pos.CENTER);
    root.setFillWidth(true);

    errorLabel = new Label("");
    errorLabel.setId("error");

    okButton = new Button("Ok");
    cancelButton = new Button("Cancel");
    defaultButton = new Button("Restore Default");

    okButton.setOnAction(e -> {
        editor.performEdit();
        hideDialog();
    });

    cancelButton.setOnAction(e -> {
        hideDialog();
    });

    defaultButton.setOnAction(e -> {
        editor.setDefaultValue();
    });

    okCancelHBox = new HBox(20);
    okCancelHBox.setPadding(new Insets(10));
    okCancelHBox.setAlignment(Pos.CENTER);
    if (restoreDefaultButton) {
        okCancelHBox.getChildren().addAll(okButton, cancelButton, defaultButton);
    } else {
        okCancelHBox.getChildren().addAll(okButton, cancelButton);
    }

    okButton.disableProperty().bind(editor.getEditDisabledProperty());
    errorLabel.visibleProperty().bind(editor.getEditDisabledProperty());
    errorLabel.textProperty().bind(editor.getErrorMessageProperty());
    final Node ec = editor.getEditorControls();
    VBox.setVgrow(ec, Priority.ALWAYS);
    root.getChildren().addAll(editor.getEditorHeading(), ec, errorLabel, okCancelHBox);

    final Scene scene = new Scene(root);
    scene.setFill(Color.rgb(0, 0, 0, 0));
    scene.getStylesheets().add(AttributeEditorDialog.class.getResource(DARK_THEME).toExternalForm());
    fxPanel.setScene(scene);
}
 
Example 17
Source File: MnistTestFXApp.java    From java-ml-projects with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	Canvas canvas = new Canvas(CANVAS_WIDTH, CANVAS_HEIGHT);
	ImageView imgView = new ImageView();
	GraphicsContext ctx = canvas.getGraphicsContext2D();
	
	model = ModelSerializer.restoreMultiLayerNetwork(new File("minist-model.zip"));
	loader = new NativeImageLoader(28,28,1,true);
	imgView.setFitHeight(100);
	imgView.setFitWidth(100);
	ctx.setLineWidth(10);
	ctx.setLineCap(StrokeLineCap.SQUARE);
	lblResult = new Label();
	
	HBox hbBottom = new HBox(10, imgView, lblResult);
	VBox root = new VBox(5, canvas, hbBottom);
	hbBottom.setAlignment(Pos.CENTER);
	root.setAlignment(Pos.CENTER);
	
	Scene scene = new Scene(root, 520, 300);
	stage.setScene(scene);
	stage.show();
	stage.setTitle("Handwritten digits recognition");
	
	canvas.setOnMousePressed(e -> {
		ctx.setStroke(Color.WHITE);
           ctx.beginPath();
           ctx.moveTo(e.getX(), e.getY());
           ctx.stroke();
	});
	canvas.setOnMouseDragged(e -> {
		ctx.setStroke(Color.WHITE);
		ctx.lineTo(e.getX(), e.getY());
		ctx.stroke();
	});
	canvas.setOnMouseClicked(e -> {
		if (e.getButton() == MouseButton.SECONDARY) {
			clear(ctx);
		}
	});
	canvas.setOnKeyReleased(e -> {
		if(e.getCode() == KeyCode.ENTER) {
               BufferedImage scaledImg = getScaledImage(canvas);
               imgView.setImage(SwingFXUtils.toFXImage(scaledImg, null));
               try {
               	predictImage(scaledImg);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
               
		}
	});
	clear(ctx);
	canvas.requestFocus();
}
 
Example 18
Source File: Exercise_16_03.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application calss
public void start(Stage primaryStage) {
	// Create a vbox
	VBox paneForCircles = new VBox(5);
	paneForCircles.setAlignment(Pos.CENTER);

	// Create three circles
	Circle c1 = getCircle();
	Circle c2 = getCircle();
	Circle c3 = getCircle();
	c1.setFill(Color.RED);

	// Place circles in vbox
	paneForCircles.getChildren().addAll(c1, c2, c3);

	// Create a rectangle
	Rectangle rectangle = new Rectangle();
	rectangle.setFill(Color.WHITE);
	rectangle.setWidth(30);
	rectangle.setHeight(100);
	rectangle.setStroke(Color.BLACK);
	rectangle.setStrokeWidth(2);
	StackPane stopSign = new StackPane(rectangle, paneForCircles);

	// Create a hbox
	HBox paneForRadioButtons = new HBox(5);
	paneForRadioButtons.setAlignment(Pos.CENTER);

	// Create radio buttons
	RadioButton rbRed = new RadioButton("Red");
	RadioButton rbYellow = new RadioButton("Yellow");
	RadioButton rbGreen = new RadioButton("Green");

	// Create a toggle group
	ToggleGroup group = new ToggleGroup();
	rbRed.setToggleGroup(group);
	rbYellow.setToggleGroup(group);
	rbGreen.setToggleGroup(group);
	rbRed.setSelected(true);
	paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbGreen);

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setCenter(stopSign);
	pane.setBottom(paneForRadioButtons);

	// Create and register handlers
	rbRed.setOnAction(e -> {
		if (rbRed.isSelected()) {
			c1.setFill(Color.RED);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.WHITE);
		}
	});

	rbYellow.setOnAction(e -> {
		if (rbYellow.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.YELLOW);
			c3.setFill(Color.WHITE);
		}
	});

	rbGreen.setOnAction(e -> {
		if (rbGreen.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.GREEN);
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 150);
	primaryStage.setTitle("Exercise_16_03"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 19
Source File: BasicView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public BasicView() {

        try {
            Class c = null;
            if (Platform.isAndroid()) {
                c = Class.forName("org.sqldroid.SQLDroidDriver");
            } else if (Platform.isIOS()) {
                c = Class.forName("SQLite.JDBCDriver");
            } else if (Platform.isDesktop()) {
                c = Class.forName("org.sqlite.JDBC");
            } else if (System.getProperty("os.arch").toUpperCase().contains("ARM")) {
                c = Class.forName("org.sqlite.JDBC");
            }
        } catch (ClassNotFoundException e) {
            System.out.println("Error class not found " + e);
        }

        listView = new ListView<>();
        listView.setPlaceholder(new Label("No items yet"));
        listView.setCellFactory(param -> {
            return new ListCell<Person>() {
                @Override
                protected void updateItem(Person item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        setText(item.getFirstName() + " " + item.getLastName());
                    } else {
                        setText(null);
                    }
                }
            };
        });

        final Label labelDB = new Label("DB Items");
        labelDB.setStyle("-fx-text-fill: gray");
        VBox vListDB = new VBox(10, labelDB, listView);
        vListDB.setAlignment(Pos.CENTER_LEFT);

        status = new ListView<>();

        final Label labelStatus = new Label("Log");
        labelStatus.setStyle("-fx-text-fill: gray");
        VBox vListStatus = new VBox(10, labelStatus, status);
        vListStatus.setAlignment(Pos.CENTER_LEFT);

        VBox controls = new VBox(20, vListDB, vListStatus);
        controls.setPadding(new Insets(10));
        controls.setAlignment(Pos.CENTER);
        
        setCenter(controls);
    }
 
Example 20
Source File: BasicView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
public BasicView() {
    
    Label label = new Label("Hello JavaFX World!");

    Button button = new Button("Change the World!");
    button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
    button.setOnAction(e -> label.setText("Hello JavaFX Universe!"));
    
    VBox controls = new VBox(15.0, label, button);
    controls.setAlignment(Pos.CENTER);
    
    setCenter(controls);
}