Search in sources :

Example 1 with HBox

use of javafx.scene.layout.HBox in project JFoenix by jfoenixadmin.

the class RadioButtonDemo method start.

@Override
public void start(Stage primaryStage) {
    try {
        final ToggleGroup group = new ToggleGroup();
        JFXRadioButton javaRadio = new JFXRadioButton("JavaFX");
        javaRadio.setPadding(new Insets(10));
        javaRadio.setToggleGroup(group);
        JFXRadioButton jfxRadio = new JFXRadioButton("JFoenix");
        jfxRadio.setPadding(new Insets(10));
        jfxRadio.setToggleGroup(group);
        HBox hbox = new HBox();
        VBox vbox = new VBox();
        vbox.getChildren().add(javaRadio);
        vbox.getChildren().add(jfxRadio);
        vbox.setSpacing(10);
        hbox.getChildren().add(vbox);
        hbox.setSpacing(50);
        hbox.setPadding(new Insets(40, 10, 10, 120));
        Scene scene = new Scene(hbox);
        primaryStage.setScene(scene);
        primaryStage.setWidth(500);
        primaryStage.setHeight(400);
        primaryStage.setTitle("JFX RadioButton Demo ");
        scene.getStylesheets().add(RadioButtonDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
        primaryStage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) ToggleGroup(javafx.scene.control.ToggleGroup) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 2 with HBox

use of javafx.scene.layout.HBox in project JFoenix by jfoenixadmin.

the class ComboBoxDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    JFXComboBox<Label> c = new JFXComboBox<>();
    c.getItems().add(new Label("Java 1.8"));
    c.getItems().add(new Label("Java 1.7"));
    c.getItems().add(new Label("Java 1.6"));
    c.getItems().add(new Label("Java 1.5"));
    c.setEditable(true);
    c.setPromptText("Select Java Version");
    HBox pane = new HBox(100);
    HBox.setMargin(c, new Insets(20));
    pane.setStyle("-fx-background-color:WHITE");
    pane.getChildren().add(c);
    final Scene scene = new Scene(pane, 300, 300);
    scene.getStylesheets().add(ComboBoxDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
    primaryStage.setTitle("JFX ComboBox Demo");
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.show();
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) JFXComboBox(com.jfoenix.controls.JFXComboBox) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene)

Example 3 with HBox

use of javafx.scene.layout.HBox in project POL-POM-5 by PlayOnLinux.

the class DetailsView method populateHeader.

/**
     * Populate the header with a label for the title of this details view and a close button
     */
private void populateHeader() {
    this.titleLabel = new Label();
    this.titleLabel.getStyleClass().add("descriptionTitle");
    this.titleLabel.setAlignment(Pos.CENTER_LEFT);
    this.titleLabel.setWrapText(true);
    this.closeButton = new Button();
    this.closeButton.getStyleClass().add("closeIcon");
    this.closeButton.setOnAction(event -> onClose.run());
    this.closeButton.setAlignment(Pos.CENTER_RIGHT);
    Region filler = new Region();
    HBox headerBox = new HBox();
    headerBox.getChildren().setAll(titleLabel, filler, closeButton);
    HBox.setHgrow(filler, Priority.ALWAYS);
    this.setTop(headerBox);
}
Also used : HBox(javafx.scene.layout.HBox) Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region)

Example 4 with HBox

use of javafx.scene.layout.HBox in project SmartCity-Market by TechnionYP5777.

the class CustomerProductCellFormat method updateItem.

@Override
public void updateItem(CartProduct item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null || empty) {
        setGraphic(null);
        setText(null);
        return;
    }
    HBox hbx = new HBox(280);
    // spacing = 5
    VBox vbx = new VBox(5);
    //vbox
    Label productName = new Label("Name: " + item.getCatalogProduct().getName());
    productName.getStyleClass().add("thisListLabel");
    //productName.setFont(new Font(20));
    Label productAmount = new Label("Amount: " + item.getTotalAmount());
    productAmount.getStyleClass().add("thisListLabel");
    //productAmount.setFont(new Font(20));
    Label productPrice = new Label("Price: " + Double.valueOf(item.getCatalogProduct().getPrice()) + " nis");
    productPrice.getStyleClass().add("thisListLabel");
    //productPrice.setFont(new Font(20));
    vbx.getChildren().addAll(productName, productAmount, productPrice);
    vbx.setAlignment(Pos.CENTER_LEFT);
    //image
    long itemBarcode = item.getCatalogProduct().getBarcode();
    URL imageUrl = null;
    try {
        imageUrl = new File("../Common/src/main/resources/ProductsPictures/" + itemBarcode + ".jpg").toURI().toURL();
    } catch (MalformedURLException e) {
        throw new RuntimeException();
    }
    Image image = new Image(imageUrl + "", 100, 100, true, false);
    ImageView productImage = new ImageView(image);
    hbx.setSpacing(230);
    hbx.getChildren().addAll(vbx, productImage);
    setGraphic(hbx);
}
Also used : HBox(javafx.scene.layout.HBox) MalformedURLException(java.net.MalformedURLException) Label(javafx.scene.control.Label) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) VBox(javafx.scene.layout.VBox) File(java.io.File) URL(java.net.URL)

Example 5 with HBox

use of javafx.scene.layout.HBox in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method setupMediaPlayer.

//private Media Player accessors / mutators
private HBox setupMediaPlayer() {
    HBox mediaSlot = new HBox();
    VBox timeControls = new VBox();
    VBox timeBox = new VBox();
    HBox mediaControlBox = new HBox();
    HBox searchBox = new HBox();
    HBox fadeBox = new HBox(5);
    VBox volumeControls = new VBox(10);
    if (Main.getMasterDataAsList().size() != 0) {
        Path path = Paths.get(Main.getMasterDataAsList().get(0).getLibraryFilePath());
        Media media = new Media(path.toFile().toURI().toString());
        player = new MediaPlayer(media);
    } else {
    //player = new MediaPlayer(new Media(Paths.get("src/com/negativevr/media_library/res/init.mp3").toFile().toURI().toString()));
    }
    //player.setAutoPlay(true);
    MediaView mediaView = new MediaView();
    mediaView.setMediaPlayer(player);
    Image PlayButtonImage = new Image("com/negativevr/media_library/res/play.png");
    Image PauseButtonImage = new Image("com/negativevr/media_library/res/pause.png");
    ImageView imageViewPlay = new ImageView(PlayButtonImage);
    ImageView imageViewPause = new ImageView(PauseButtonImage);
    play = new Button();
    play.setGraphic(imageViewPlay);
    play.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            updateValues();
            Status status = player.getStatus();
            if (status == Status.PAUSED || status == Status.READY || status == Status.UNKNOWN || status == Status.STOPPED) {
                player.play();
                play.setGraphic(imageViewPause);
            } else {
                player.pause();
                play.setGraphic(imageViewPlay);
            }
        }
    });
    reload = new Button();
    reload.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/reload.png")));
    reload.setOnAction((ActionEvent e) -> {
        player.seek(player.getStartTime());
    });
    skip = new Button();
    skip.setGraphic((new ImageView(new Image("com/negativevr/media_library/res/skip.png"))));
    skip.setOnAction((ActionEvent e) -> {
        player.seek(player.getStopTime());
    });
    previous = new Button();
    previous.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/previous.png")));
    next = new Button();
    next.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/next.png")));
    Button repeat = new Button();
    if (status == MediaStatus.REPEAT_NONE)
        repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_none.png")));
    else if (status == MediaStatus.REPEAT_SINGLE)
        repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_single.png")));
    repeat.setOnAction((ActionEvent e) -> {
        if (status == MediaStatus.REPEAT_SINGLE) {
            status = MediaStatus.REPEAT_NONE;
            repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_none.png")));
        } else if (status == MediaStatus.REPEAT_NONE) {
            status = MediaStatus.REPEAT_SINGLE;
            repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_single.png")));
        }
    });
    timeSlider = new Slider();
    HBox.setHgrow(timeSlider, Priority.ALWAYS);
    timeSlider.setMinSize(100, 50);
    timeSlider.valueProperty().addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable ov) {
            if (timeSlider.isValueChanging()) {
                Duration duration = player.getMedia().getDuration();
                if (duration != null) {
                    player.seek(duration.multiply(timeSlider.getValue() / 100.0));
                }
                updateValues();
            }
        }
    });
    List<MediaFile> data = Main.getMasterDataAsList();
    if (data.size() != 0) {
        artistLabel = new Label(data.get(0).getArtistName() + " - " + data.get(0).getAlbumName());
        songLabel = new Label(data.get(0).getSongName());
    } else {
        artistLabel = new Label();
        songLabel = new Label();
    }
    player.currentTimeProperty().addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable ov) {
            updateValues();
        }
    });
    player.currentTimeProperty().addListener(new ChangeListener<Duration>() {

        @Override
        public void changed(ObservableValue<? extends Duration> arg0, Duration arg1, Duration arg2) {
            updateValues();
        }
    });
    time = new Label();
    time.setTextFill(Color.BLACK);
    player.setOnReady(() -> {
        duration = player.getMedia().getDuration();
        updateValues();
    });
    //volume control slider
    volumeSlider = new Slider(0, 1, 0);
    player.volumeProperty().bindBidirectional(volumeSlider.valueProperty());
    player.setVolume(0.5);
    //fade in time line
    final Timeline fadeInTimeline = new Timeline(new KeyFrame(FADE_DURATION, new KeyValue(player.volumeProperty(), 1.0)));
    //fade out timeline
    final Timeline fadeOutTimeline = new Timeline(new KeyFrame(FADE_DURATION, new KeyValue(player.volumeProperty(), 0.0)));
    //fade in button
    fadeIn = new Button("Fade In");
    fadeIn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            fadeInTimeline.play();
        }
    });
    fadeIn.setMaxWidth(Double.MAX_VALUE);
    //fade out button
    fadeOut = new Button("Fade Out");
    fadeOut.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            fadeOutTimeline.play();
        }
    });
    fadeOut.setMaxWidth(Double.MAX_VALUE);
    player.setOnEndOfMedia(() -> {
        play.setGraphic(imageViewPlay);
        if (status == MediaStatus.REPEAT_NONE) {
            player.seek(new Duration(0));
            player.pause();
            play.setGraphic(imageViewPlay);
        } else if (status == MediaStatus.REPEAT_SINGLE) {
            player.seek(new Duration(0));
            player.play();
            play.setGraphic(imageViewPause);
        }
    });
    //volume cotrol box
    fadeBox.getChildren().addAll(fadeOut, fadeIn);
    fadeBox.setAlignment(Pos.CENTER);
    volumeControls.getChildren().setAll(new Label("Volume"), volumeSlider, fadeBox);
    volumeControls.setAlignment(Pos.CENTER);
    volumeControls.disableProperty().bind(Bindings.or(Bindings.equal(Timeline.Status.RUNNING, fadeInTimeline.statusProperty()), Bindings.equal(Timeline.Status.RUNNING, fadeOutTimeline.statusProperty())));
    timeControls.getChildren().addAll(songLabel, artistLabel, timeSlider);
    timeControls.setAlignment(Pos.CENTER);
    timeControls.setFillWidth(true);
    timeControls.setMinWidth(300);
    timeBox.getChildren().addAll(repeat, time);
    timeBox.setAlignment(Pos.CENTER);
    mediaControlBox.getChildren().addAll(previous, reload, play, skip, next);
    mediaControlBox.setAlignment(Pos.CENTER);
    searchBox.getChildren().addAll(new Label("Search"), search);
    searchBox.setAlignment(Pos.CENTER_RIGHT);
    mediaSlot.getChildren().addAll(mediaControlBox, timeBox, timeControls, volumeControls, mediaView, searchBox);
    mediaSlot.setSpacing(10);
    HBox.setHgrow(timeControls, Priority.ALWAYS);
    return mediaSlot;
}
Also used : HBox(javafx.scene.layout.HBox) KeyValue(javafx.animation.KeyValue) Slider(javafx.scene.control.Slider) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) Image(javafx.scene.image.Image) MediaView(javafx.scene.media.MediaView) Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) ImageView(javafx.scene.image.ImageView) Path(java.nio.file.Path) Status(javafx.scene.media.MediaPlayer.Status) MediaFile(com.negativevr.media_library.files.MediaFile) Media(javafx.scene.media.Media) Duration(javafx.util.Duration) Observable(javafx.beans.Observable) Timeline(javafx.animation.Timeline) InvalidationListener(javafx.beans.InvalidationListener) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox) MediaPlayer(javafx.scene.media.MediaPlayer)

Aggregations

HBox (javafx.scene.layout.HBox)54 Button (javafx.scene.control.Button)25 Insets (javafx.geometry.Insets)22 Label (javafx.scene.control.Label)22 Scene (javafx.scene.Scene)12 VBox (javafx.scene.layout.VBox)11 BorderPane (javafx.scene.layout.BorderPane)8 Node (javafx.scene.Node)7 InputTextField (io.bitsquare.gui.components.InputTextField)6 TextArea (javafx.scene.control.TextArea)6 Stage (javafx.stage.Stage)6 Popup (io.bitsquare.gui.main.overlays.popups.Popup)5 IOException (java.io.IOException)5 ObservableList (javafx.collections.ObservableList)5 FXML (javafx.fxml.FXML)5 ImageView (javafx.scene.image.ImageView)5 KeyFrame (javafx.animation.KeyFrame)4 Timeline (javafx.animation.Timeline)4 File (java.io.File)3 Group (javafx.scene.Group)3