javafx.scene.layout.HBox Java Examples

The following examples show how to use javafx.scene.layout.HBox. 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: CheckListFormNode.java    From marathonv5 with Apache License 2.0 8 votes vote down vote up
private VBox createDescriptionField() {
    VBox descriptionFieldBox = new VBox();
    TextArea descriptionArea = new TextArea();
    descriptionArea.setPrefRowCount(4);
    descriptionArea.textProperty().addListener((observable, oldValue, newValue) -> {
        fireContentChanged();
        checkList.setDescription(descriptionArea.getText());
    });
    descriptionArea.setEditable(mode.isSelectable());
    descriptionFieldBox.getChildren().addAll(new Label("Description"), descriptionArea);
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    VBox.setMargin(descriptionFieldBox, new Insets(5, 10, 5, 5));
    descriptionArea.setText(checkList.getDescription());
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    HBox.setHgrow(descriptionFieldBox, Priority.ALWAYS);
    return descriptionFieldBox;
}
 
Example #2
Source File: CheckedNumberTextField.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public CheckedNumberTextField(final double initialValue) {
    super(Double.toString(initialValue));

    final ValidationSupport support = new ValidationSupport();
    final Validator<String> validator = (final Control control, final String value) -> {
        final boolean condition = value == null || !(value.matches(CheckedNumberTextField.NUMBER_REGEX) || CheckedNumberTextField.isNumberInfinity(value));

        // change text colour depending on validity as a number
        setStyle(condition ? "-fx-text-inner-color: red;" : "-fx-text-inner-color: black;");
        return ValidationResult.fromMessageIf(control, "not a number", Severity.ERROR, condition);
    };
    support.registerValidator(this, true, validator);

    snappedTopInset();
    snappedBottomInset();
    HBox.setHgrow(this, Priority.ALWAYS);
    VBox.setVgrow(this, Priority.ALWAYS);
}
 
Example #3
Source File: LodLevelPropertyControl.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void createComponents(@NotNull HBox container) {
    super.createComponents(container);

    levelComboBox = new ComboBox<>();
    levelComboBox.setCellFactory(param -> new LodLevelCell());
    levelComboBox.setButtonCell(new LodLevelCell());
    levelComboBox.setEditable(false);
    levelComboBox.prefWidthProperty()
            .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FxControlUtils.onSelectedItemChange(levelComboBox, this::updateLevel);

    FxUtils.addClass(levelComboBox,
            CssClasses.PROPERTY_CONTROL_COMBO_BOX);

    FxUtils.addChild(container, levelComboBox);
}
 
Example #4
Source File: SettingNumberField.java    From MSPaintIDE with MIT License 6 votes vote down vote up
public SettingNumberField() {
    getStyleClass().add("theme-text");
    setStyle("-fx-padding: 10px 0");
    label.getStyleClass().add("theme-text");
    numberField.getStyleClass().add("theme-text");


    Node spacer = getHSpacer(10);
    HBox.setHgrow(label, Priority.NEVER);
    HBox.setHgrow(numberField, Priority.NEVER);
    HBox.setHgrow(spacer, Priority.NEVER);

    label.setPrefHeight(25);
    getChildren().add(label);
    getChildren().add(spacer);
    getChildren().add(numberField);
    numberField.textProperty().addListener(((observable, oldValue, newValue) -> SettingsManager.getInstance().setSetting(settingProperty.get(), newValue.isEmpty() ? 0 : Integer.valueOf(newValue))));
}
 
Example #5
Source File: TextElement.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
@Override
protected void setupMenu(){

	NodeMenuItem item1 = new NodeMenuItem(new HBox(), TR.tr("Supprimer"), false);
	item1.setAccelerator(new KeyCodeCombination(KeyCode.DELETE));
	item1.setToolTip(TR.tr("Supprime cet élément. Il sera donc retiré de l'édition."));
	NodeMenuItem item2 = new NodeMenuItem(new HBox(), TR.tr("Dupliquer"), false);
	item2.setToolTip(TR.tr("Crée un second élément identique à celui-ci."));
	NodeMenuItem item3 = new NodeMenuItem(new HBox(), TR.tr("Ajouter aux éléments précédents"), false);
	item3.setToolTip(TR.tr("Ajoute cet élément à la liste des éléments précédents."));
	NodeMenuItem item4 = new NodeMenuItem(new HBox(), TR.tr("Ajouter aux éléments Favoris"), false);
	item4.setToolTip(TR.tr("Ajoute cet élément à la liste des éléments favoris."));
	menu.getItems().addAll(item1, item2, item4, item3);
	NodeMenuItem.setupMenu(menu);

	item1.setOnAction(e -> delete());
	item2.setOnAction(e -> cloneOnDocument());
	item3.setOnAction(e -> TextTreeView.addSavedElement(this.toNoDisplayTextElement(TextTreeSection.LAST_TYPE, true)));
	item4.setOnAction(e -> TextTreeView.addSavedElement(this.toNoDisplayTextElement(TextTreeSection.FAVORITE_TYPE, true)));
}
 
Example #6
Source File: CellUtiles.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    textField.setText(getItemText(cell, converter));
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
Example #7
Source File: PmMap.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
protected Marker createMarker(final LatLong lat, final String title) {
	final MarkerOptions options = new MarkerOptions();
	options.position(lat).title(title).visible(true);
	final Marker $ = new MyMarker(options, title, lat);
	markers.add($);
	fromLocation.getItems().add(title);
	toLocation.getItems().add(title);
	final HBox hbox = new HBox();
	hbox.setPadding(new Insets(8, 5, 8, 5));
	hbox.setSpacing(8);
	final Label l = new Label(title);
	final Button btn = new Button("remove");
	btn.setOnAction(λ -> {
		map.removeMarker($);
		markerVbox.getChildren().remove(hbox);
		fromLocation.getItems().remove(title);
		toLocation.getItems().remove(title);
	});
	btns.add(btn);
	hbox.getChildren().addAll(l, btn);
	VBox.setMargin(hbox, new Insets(0, 0, 0, 8));
	markerVbox.getChildren().add(hbox);
	return $;

}
 
Example #8
Source File: TransactionTypeNodeProvider.java    From constellation with Apache License 2.0 6 votes vote down vote up
private VBox addFilter() {
    filterText.setPromptText("Filter transaction types");
    final ToggleGroup toggleGroup = new ToggleGroup();
    startsWithRb.setToggleGroup(toggleGroup);
    startsWithRb.setPadding(new Insets(0, 0, 0, 5));
    startsWithRb.setSelected(true);
    final RadioButton containsRadioButton = new RadioButton("Contains");
    containsRadioButton.setToggleGroup(toggleGroup);
    containsRadioButton.setPadding(new Insets(0, 0, 0, 5));

    toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    filterText.textProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRadioButton);
    headerBox.setAlignment(Pos.CENTER_LEFT);
    headerBox.setPadding(new Insets(5));

    final VBox box = new VBox(schemaLabel, headerBox, treeView);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    return box;
}
 
Example #9
Source File: App.java    From java-ml-projects with Apache License 2.0 6 votes vote down vote up
private Parent buildUI() {
	fc = new FileChooser();
	fc.getExtensionFilters().clear();
	ExtensionFilter jpgFilter = new ExtensionFilter("JPG, JPEG images", "*.jpg", "*.jpeg", "*.JPG", ".JPEG");
	fc.getExtensionFilters().add(jpgFilter);
	fc.setSelectedExtensionFilter(jpgFilter);
	fc.setTitle("Select a JPG image");
	lstLabels = new ListView<>();
	lstLabels.setPrefHeight(200);
	Button btnLoad = new Button("Select an Image");
	btnLoad.setOnAction(e -> validateUrlAndLoadImg());

	HBox hbBottom = new HBox(10, btnLoad);
	hbBottom.setAlignment(Pos.CENTER);

	loadedImage = new ImageView();
	loadedImage.setFitWidth(300);
	loadedImage.setFitHeight(250);
	
	Label lblTitle = new Label("Label image using TensorFlow");
	lblTitle.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, 40));
	VBox root = new VBox(10,lblTitle, loadedImage, new Label("Results:"), lstLabels, hbBottom);
	root.setAlignment(Pos.TOP_CENTER);
	return root;
}
 
Example #10
Source File: ImageValueEditor.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public ImageValueEditor() {
	HBox.setHgrow(tfFilePath, Priority.ALWAYS);
	tfFilePath.setEditable(false);
	btnChooseImage.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			FileChooser fc = new FileChooser();
			fc.setTitle(bundle.getString("ValueEditors.ImageValueEditor.locate_image"));
			fc.getExtensionFilters().addAll(ADCStatic.IMAGE_FILE_EXTENSIONS);
			fc.setInitialDirectory(Workspace.getWorkspace().getWorkspaceDirectory());
			File chosenFile = fc.showOpenDialog(ArmaDialogCreator.getPrimaryStage());
			if (chosenFile == null) {
				return;
			}
			chooseImage(chosenFile);
		}
	});
}
 
Example #11
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane,
                                                                          int rowIndex,
                                                                          String title,
                                                                          String buttonTitle,
                                                                          double top) {

    TextField textField = new BisqTextField();
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(textField, button);
    HBox.setHgrow(textField, Priority.ALWAYS);

    final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple3<>(labelVBoxTuple2.first, textField, button);
}
 
Example #12
Source File: ConfigTreeItem.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
private void initTreeItemValue() {
    HBox itemContainer = new HBox();
    itemContainer.setSpacing(5d);
    itemContainer.getChildren().add(createLabel());

    Region spacing = new Region();
    spacing.setMaxHeight(0d);
    HBox.setHgrow(spacing, Priority.ALWAYS);
    itemContainer.getChildren().add(spacing);

    if (configNode.isRemovable()) {
        itemContainer.getChildren().add(createRemoveButton());
    }

    this.control = createControl();
    if (control != null) {
        itemContainer.getChildren().add(control);
    }

    setValue(itemContainer);
}
 
Example #13
Source File: FloatPropertyControl.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void createComponents(@NotNull HBox container) {
    super.createComponents(container);

    valueField = new FloatTextField();
    valueField.prefWidthProperty()
        .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FxControlUtils.onValueChange(valueField, this::updateValue);
    FxControlUtils.onFocusChange(valueField, this::applyOnLostFocus);

    FxUtils.addClass(valueField,
            CssClasses.PROPERTY_CONTROL_COMBO_BOX);

    FxUtils.addChild(container, valueField);
}
 
Example #14
Source File: RepositoriesPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a container for the refresh button
 *
 * @return A container with the refresh button
 */
private HBox createRefreshButtonContainer() {
    final Label refreshRepositoriesLabel = new Label(
            tr("Fetch updates from the repositories to retrieve latest script versions"));
    refreshRepositoriesLabel.getStyleClass().add("repositories-refresh-label");

    HBox.setHgrow(refreshRepositoriesLabel, Priority.ALWAYS);

    final Button refreshRepositoriesButton = new Button(tr("Refresh Repositories"));
    refreshRepositoriesButton.setOnAction(
            event -> Optional.ofNullable(getControl().getOnRepositoryRefresh()).ifPresent(Runnable::run));

    final HBox container = new HBox(refreshRepositoriesLabel, refreshRepositoriesButton);

    container.getStyleClass().add("repositories-refresh-container");

    return container;
}
 
Example #15
Source File: MarioLoadingScene.java    From FXGLGames with MIT License 5 votes vote down vote up
public MarioLoadingScene() {
    var bg = new Rectangle(getAppWidth(), getAppHeight(), Color.AZURE);

    var text = getUIFactoryService().newText("Loading level", Color.BLACK, 46.0);
    centerText(text, getAppWidth() / 2, getAppHeight() / 3  + 25);

    var hbox = new HBox(5);

    for (int i = 0; i < 3; i++) {
        var textDot = getUIFactoryService().newText(".", Color.BLACK, 46.0);

        hbox.getChildren().add(textDot);

        animationBuilder(this)
                .autoReverse(true)
                .delay(Duration.seconds(i * 0.5))
                .repeatInfinitely()
                .fadeIn(textDot)
                .buildAndPlay();
    }

    hbox.setTranslateX(getAppWidth() / 2 - 20);
    hbox.setTranslateY(getAppHeight() / 2);

    var playerTexture = texture("player.png").subTexture(new Rectangle2D(0, 0, 32, 42));
    playerTexture.setTranslateX(getAppWidth() / 2 - 32/2);
    playerTexture.setTranslateY(getAppHeight() / 2 - 42/2);

    animationBuilder(this)
            .duration(Duration.seconds(1.25))
            .repeatInfinitely()
            .autoReverse(true)
            .interpolator(Interpolators.EXPONENTIAL.EASE_IN_OUT())
            .rotate(playerTexture)
            .from(0)
            .to(360)
            .buildAndPlay();

    getContentRoot().getChildren().setAll(bg, text, hbox, playerTexture);
}
 
Example #16
Source File: FGaugeDemo.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    HBox pane = new HBox(fGauge, button);
    pane.setPadding(new Insets(10));
    pane.setSpacing(20);

    Scene scene = new Scene(pane);

    stage.setTitle("FGauge Demo");
    stage.setScene(scene);
    stage.show();
}
 
Example #17
Source File: TextureLayerSettings.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@FxThread
private void createComponents() {

    this.listView = new ListView<>();
    this.listView.setCellFactory(param -> newCell());
    this.listView.setEditable(false);
    this.listView.prefWidthProperty().bind(widthProperty());

    final MultipleSelectionModel<TextureLayer> selectionModel = listView.getSelectionModel();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> updateSelectedLayer(newValue));

    addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_16));
    addButton.setOnAction(event -> addLayer());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_16));
    removeButton.setOnAction(event -> removeLayer());
    removeButton.disableProperty().bind(selectionModel.selectedItemProperty().isNull());

    final HBox buttonContainer = new HBox(addButton, removeButton);

    FXUtils.addToPane(listView, this);
    FXUtils.addToPane(buttonContainer, this);

    FXUtils.addClassesTo(listView, CssClasses.TRANSPARENT_LIST_VIEW, CssClasses.LIST_VIEW_WITHOUT_SCROLL);
    FXUtils.addClassTo(buttonContainer, CssClasses.PROCESSING_COMPONENT_TERRAIN_EDITOR_LAYERS_SETTINGS_BUTTONS);
    FXUtils.addClassTo(addButton, CssClasses.BUTTON_WITHOUT_RIGHT_BORDER);
    FXUtils.addClassTo(removeButton, CssClasses.BUTTON_WITHOUT_LEFT_BORDER);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
Example #18
Source File: DefaultPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createComponents(@NotNull HBox container) {
    super.createComponents(container);

    propertyValueLabel = new Label();
    propertyValueLabel.prefWidthProperty()
            .bind(container.widthProperty());

    FxUtils.addClass(propertyValueLabel,
            CssClasses.ABSTRACT_PARAM_CONTROL_LABEL_VALUE,
            CssClasses.TEXT_INPUT_CONTAINER);

    FxUtils.addChild(container, propertyValueLabel);
}
 
Example #19
Source File: RequestCollectionComponent.java    From milkman with MIT License 5 votes vote down vote up
public TreeItem<Node> buildTree(Collection collection){
	SettableTreeItem<Node> item = new SettableTreeItem<Node>();
	HBox collEntry = createCollectionEntry(collection, item);
	item.setValue(collEntry);
	item.getValue().setUserData(collection);
	item.setExpanded(expansionCache.getOrDefault(collection.getId(), false));
	item.expandedProperty().addListener((obs, o, n) -> {
		expansionCache.put(collection.getId(), n);
	});

	
	List<RequestContainer> collectionRequests = new LinkedList<>(collection.getRequests());
	
	List<TreeItem<Node>> children = new LinkedList<TreeItem<Node>>();
	for (Folder f : collection.getFolders()) {
		SettableTreeItem<Node> folderItm = buildTreeForFolder(collection, f, collectionRequests);
		children.add(folderItm);
	}
	
	
	for (RequestContainer r : collectionRequests) {
		TreeItem<Node> requestTreeItem = new TreeItem<Node>(createRequestEntry(collection, r));
		requestTreeItem.getValue().setUserData(r);
		children.add(requestTreeItem);
	}
	item.setChildren(new FilteredList<TreeItem<Node>>(FXCollections.observableList(children)));
	return item;
}
 
Example #20
Source File: LinearGradientSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public LinearGradientSample() {
    //First rectangle
    Rectangle rect1 = new Rectangle(0,0,80,80);

    //create simple linear gradient
    LinearGradient gradient1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(1, Color.BLACK)
    });

    //set rectangle fill
    rect1.setFill(gradient1);

    // Second rectangle
    Rectangle rect2 = new Rectangle(0,0,80,80);

    //create complex linear gradient
    LinearGradient gradient2 = new LinearGradient(0, 0, 0, 0.5,  true, CycleMethod.REFLECT, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(0.1, Color.BLACK),
        new Stop(1, Color.DODGERBLUE)
    });

    //set rectangle fill
    rect2.setFill(gradient2);

    // show the rectangles
    HBox hb = new HBox(10);
    hb.getChildren().addAll(rect1, rect2);
    getChildren().add(hb);
}
 
Example #21
Source File: Main.java    From regulators with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    HBox pane = new HBox(regulator, feedbackRegulator, colorRegulator);
    pane.setSpacing(20);
    pane.setPadding(new Insets(10));
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(66,71,79), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example #22
Source File: Exercise_14_04.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 HBox
	HBox hBox = new HBox(10);
	hBox.setPadding(new Insets(10, 10, 10, 10));
	hBox.setAlignment(Pos.CENTER);

	// Add text to hBox
	for (int i = 0; i < 5; i++) {
		// Crate a Text and set its properties
		Text text = new Text("Java");
		text.setFont(Font.font("Times Roman", FontWeight.BOLD,
		FontPosture.ITALIC, 22));
		text.setRotate(90);

		// Set a random color and opacity
		text.setFill(new Color(Math.random(), Math.random(), 
			Math.random(), Math.random()));
		hBox.getChildren().add(text);
	}

	// Create a scene and place it in the stage
	Scene scene = new Scene(hBox, 300, 100);
	primaryStage.setTitle("Exercise_14_04"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example #23
Source File: Exercise_16_22.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 three buttons
	Button play = new Button("Play");
	Button loop = new Button("Loop");
	Button stop = new Button("Stop");

	// Create a pane and set its properties
	HBox pane = new HBox(5);
	pane.setAlignment(Pos.CENTER);
	pane.setPadding(new Insets(10, 10, 10, 10));
	pane.getChildren().addAll(play, loop, stop);

	// Create a audio clip
	AudioClip audio = new AudioClip(
		"http://cs.armstrong.edu/liang/common/audio/anthem/anthem3.mp3");

	// Create and register handlers
	play.setOnAction(e -> {
		audio.play();
	});

	stop.setOnAction(e -> {
		audio.stop();
	});

	loop.setOnAction(e -> {
		audio.setCycleCount(AudioClip.INDEFINITE);
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_16_22"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example #24
Source File: ChatBoxTimed.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    final Clock clock = new Clock(Duration.seconds(1), true);
    
    final BorderPane root = new BorderPane();
    final HBox controls = new HBox(5);
    controls.setAlignment(Pos.CENTER);
    controls.setPadding(new Insets(10));
    
    final TextField itemField = new TextField();
    itemField.setTooltip(new Tooltip("Type an item and press Enter"));
    controls.getChildren().add(itemField);
    
    final VBox items = new VBox(5);
    
    itemField.setOnAction(event -> {
        String text = itemField.getText();
        Label label = new Label();
        label.textProperty().bind(Bindings.format("%s (%s)", text, clock.getElapsedStringBinding()));
        items.getChildren().add(label);
        itemField.setText("");
    });
    
    final ScrollPane scroller = new ScrollPane();
    scroller.setContent(items);
    
    final Label currentTimeLabel = new Label();
    currentTimeLabel.textProperty().bind(Bindings.format("Current time: %s", clock.getTimeStringBinding()));
    
    root.setTop(controls);
    root.setCenter(scroller);
    root.setBottom(currentTimeLabel);
    
    Scene scene = new Scene(root, 600, 400);
    
    primaryStage.setTitle("Timed item display");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #25
Source File: JavaFxSelectionComponentFactory.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
FileSelector(
    final ClientSetting<Path> clientSetting,
    final BiFunction<Window, /* @Nullable */ Path, /* @Nullable */ Path> chooseFile) {
  this.clientSetting = clientSetting;
  final @Nullable Path initialValue = clientSetting.getValue().orElse(null);
  final HBox wrapper = new HBox();
  textField = new TextField(SelectionComponentUiUtils.toString(clientSetting.getValue()));
  textField
      .prefColumnCountProperty()
      .bind(Bindings.add(1, Bindings.length(textField.textProperty())));
  textField.setMaxWidth(Double.MAX_VALUE);
  textField.setMinWidth(100);
  textField.setDisable(true);
  final Button chooseFileButton = new Button("...");
  selectedPath = initialValue;
  chooseFileButton.setOnAction(
      e -> {
        final @Nullable Path path =
            chooseFile.apply(chooseFileButton.getScene().getWindow(), selectedPath);
        if (path != null) {
          selectedPath = path;
          textField.setText(path.toString());
        }
      });
  wrapper.getChildren().addAll(textField, chooseFileButton);
  getChildren().add(wrapper);
}
 
Example #26
Source File: Story.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/** @return the content of the address, with a signature and portrait attached. */
private Pane getContent() {
  final VBox content = new VBox();
  content.getStyleClass().add("address");

  //int rand = RandomUtil.getRandomInt(1);

  final Label address = new Label(START1+START2+MID1+MID2+MID3+MID4);

  address.setWrapText(true);
  ScrollPane addressScroll = makeScrollable(address);

  final ImageView signature = new ImageView(); signature.setId("signature");
  final ImageView lincolnImage = new ImageView(); lincolnImage.setId("portrait");
  VBox.setVgrow(addressScroll, Priority.ALWAYS);

  final Region spring = new Region();
  HBox.setHgrow(spring, Priority.ALWAYS);
  
  //final Node alignedSignature = HBoxBuilder.create().children(spring, signature).build();
  final HBox alignedSignature = new HBox(spring, signature);
  
  Label date = new Label(DATE);
  date.setAlignment(Pos.BOTTOM_RIGHT);

  content.getChildren().addAll(
      lincolnImage,
      addressScroll,
      alignedSignature,
      date
  );

  return content;
}
 
Example #27
Source File: HashController.java    From dev-tools with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initialize(URL location, ResourceBundle resources) {
    hashAlgoSelector.getItems().setAll("md5", "sha1", "sha256", "murmur3_128",
            "Url encode", "Url decode",
            "Base64 encode", "Base64 decode");
    hashMessage.setPadding(new Insets(5));
    hashMessage.setTextFill(Color.RED);

    HBox.setMargin(hashAlgoSelector, new Insets(10, 5, 10, 0));
    HBox.setMargin(hashCalculateButton, new Insets(10, 5, 10, 0));
    HBox.setMargin(hashMoveUpButton, new Insets(10, 5, 10, 0));
    HBox.setMargin(hashClearButton, new Insets(10, 5, 10, 0));
    HBox.setMargin(hashMessage, new Insets(10, 5, 10, 0));
}
 
Example #28
Source File: ViewNumberChart.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Node constructContent() {
    VBox vboxroot = new VBox();
    vboxroot.setSpacing(10.0);   
    
    boxview = new HBox();
    boxview.setSpacing(6.0);
    
    level = new Label();
    level.setAlignment(Pos.CENTER_RIGHT);
    level.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    level.getStyleClass().add("unitmaintext");
    HBox.setHgrow(level, Priority.SOMETIMES);
    
    boxview.getChildren().add(level);
    
    areachart = new ChartNode();
    StackPane chart = areachart.getNode();
    chart.setMinSize(40.0, 50.0);
    chart.setPrefSize(40.0, 50.0);
    chart.setPadding(Insets.EMPTY);
    
    StackPane stack = new StackPane(chart);
    VBox.setVgrow(stack, Priority.SOMETIMES);   
    stack.setPadding(new Insets(0.0, 0.0, 0.0, 3.0));
    vboxroot.getChildren().addAll(boxview, stack);
    
    initialize();
    return vboxroot;
}
 
Example #29
Source File: CameraStream.java    From tutorials with MIT License 5 votes vote down vote up
public void start(Stage stage) throws Exception {
    OpenCV.loadShared();
    capture=  new VideoCapture(0); // The number is the ID of the camera
    ImageView imageView = new ImageView();
    HBox hbox = new HBox(imageView);
    Scene scene = new Scene(hbox);
    stage.setScene(scene);
    stage.show();
    new AnimationTimer(){
        @Override
        public void handle(long l) {
            imageView.setImage(getCapture());
        }
    }.start();
}
 
Example #30
Source File: ConsoleWindow.java    From SmartModInserter with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ProcessTab(Process process) {
    this.process = process;

    hbox = new HBox();
    vbox = new VBox(log, hbox);

    Button killButton = new Button("Kill");
    killButton.setOnAction((e) -> {
        process.destroyForcibly();
    });

    hbox.setAlignment(Pos.CENTER_RIGHT);
    hbox.getChildren().add(killButton);

    VBox.setVgrow(log, Priority.ALWAYS);
    this.setContent(vbox);
    log.setWrapText(true);
    log.setFont(Font.font("Courier", 12));

    reader = new Thread(() -> {
        BufferedReader stream = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line = null;
        try {
            while ((line = stream.readLine()) != null) {
                final String tmpLine = line;
                Platform.runLater(() -> {
                    String old = log.getText();
                    old += tmpLine;
                    old += "\n";
                    log.setText(old);
                    log.setScrollTop(Double.MAX_VALUE);
                });
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    });
    reader.start();
}