Java Code Examples for javafx.scene.layout.GridPane#add()

The following examples show how to use javafx.scene.layout.GridPane#add() . 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: RenameDialog.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void createContent(@NotNull final GridPane root) {
    super.createContent(root);

    final Label nameLabel = new Label(Messages.RENAME_DIALOG_NEW_NAME_LABEL + ":");
    nameLabel.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_LABEL_W_PERCENT));

    nameField = new TextField();
    nameField.textProperty().addListener((observable, oldValue, newValue) -> validateName(newValue));
    nameField.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));

    root.add(nameLabel, 0, 0);
    root.add(nameField, 1, 0);

    FXUtils.addClassTo(nameLabel, CssClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(nameField, CssClasses.DIALOG_FIELD);
}
 
Example 2
Source File: RadioChooserDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Build up a single columns of buttons
 * @return pane with radio buttons
 */
private Pane buildNormalColLayout()
{
	GridPane boxPane = new GridPane();
	int numButtons = avaRadioButton.length;
	for (int row = 0; row < numButtons; ++row)
	{
		boxPane.add(avaRadioButton[row], 0, row);
	}
	return boxPane;
}
 
Example 3
Source File: ActivityDashboard.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void init() {
    GaugeBuilder builder = GaugeBuilder.create()
                                       .skinType(SkinType.SLIM)
                                       .barBackgroundColor(MaterialDesign.GREY_800.get())
                                       .animated(true)
                                       .animationDuration(1000);
    steps        = builder.decimals(0).maxValue(10000).unit("STEPS").build();
    distance     = builder.decimals(2).maxValue(10).unit("KM").build();
    actvCalories = builder.decimals(0).maxValue(2200).unit("KCAL").build();
    foodCalories = builder.decimals(0).maxValue(2200).unit("KCAL").build();
    weight       = builder.decimals(1).maxValue(85).unit("KG").build();
    bodyFat      = builder.decimals(1).maxValue(20).unit("%").build();

    VBox stepsBox        = getVBox("STEPS", MaterialDesign.CYAN_300.get(), steps);
    VBox distanceBox     = getVBox("DISTANCE", MaterialDesign.ORANGE_300.get(), distance);
    VBox actvCaloriesBox = getVBox("ACTIVE CALORIES", MaterialDesign.RED_300.get(), actvCalories);
    VBox foodCaloriesBox = getVBox("FOOD", MaterialDesign.GREEN_300.get(), foodCalories);
    VBox weightBox       = getVBox("WEIGHT", MaterialDesign.DEEP_PURPLE_300.get(), weight);
    VBox bodyFatBox      = getVBox("BODY FAT", MaterialDesign.PURPLE_300.get(), bodyFat);

    pane = new GridPane();
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(15);
    pane.setBackground(new Background(new BackgroundFill(MaterialDesign.GREY_900.get(), CornerRadii.EMPTY, Insets.EMPTY)));
    pane.add(stepsBox, 0, 0);
    pane.add(distanceBox, 1, 0);
    pane.add(actvCaloriesBox, 0, 2);
    pane.add(foodCaloriesBox, 1, 2);
    pane.add(weightBox, 0, 4);
    pane.add(bodyFatBox, 1, 4);
}
 
Example 4
Source File: CreateSceneAppStateDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createContent(@NotNull final GridPane root) {
    super.createContent(root);

    final Label customBoxLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_BOX + ":");
    customBoxLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    customCheckBox = new CheckBox();
    customCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label builtInLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_BUILT_IN + ":");
    builtInLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    builtInBox = new ComboBox<>();
    builtInBox.disableProperty().bind(customCheckBox.selectedProperty());
    builtInBox.getItems().addAll(BUILT_IN_NAMES);
    builtInBox.getSelectionModel().select(BUILT_IN_NAMES.first());
    builtInBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label customNameLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_FIELD + ":");
    customNameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    stateNameField = new TextField();
    stateNameField.disableProperty().bind(customCheckBox.selectedProperty().not());
    stateNameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final GridPane settingsContainer = new GridPane();
    root.add(builtInLabel, 0, 0);
    root.add(builtInBox, 1, 0);
    root.add(customBoxLabel, 0, 1);
    root.add(customCheckBox, 1, 1);
    root.add(customNameLabel, 0, 2);
    root.add(stateNameField, 1, 2);

    FXUtils.addToPane(settingsContainer, root);

    FXUtils.addClassTo(builtInLabel, customBoxLabel, customNameLabel, CssClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(builtInBox, customCheckBox, stateNameField, CssClasses.DIALOG_FIELD);
}
 
Example 5
Source File: ProgressIndicatorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public ProgressIndicatorSample() {
    super(400,400);
    
    GridPane g = new GridPane();

    ProgressIndicator p1 = new ProgressIndicator();
    p1.setPrefSize(50, 50);

    ProgressIndicator p2 = new ProgressIndicator();
    p2.setPrefSize(50, 50);
    p2.setProgress(0.25F);

    ProgressIndicator p3 = new ProgressIndicator();
    p3.setPrefSize(50, 50);
    p3.setProgress(0.5F);

    ProgressIndicator p4 = new ProgressIndicator();
    p4.setPrefSize(50, 50);
    p4.setProgress(1.0F);

    g.add(p1, 1, 0);
    g.add(p2, 0, 1);
    g.add(p3, 1, 1);
    g.add(p4, 2, 1);

    g.setHgap(40);
    g.setVgap(40);
    
    getChildren().add(g);
}
 
Example 6
Source File: ActionsDialog.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @return Sub-pane for WritePV action */
private GridPane createWritePVDetails()
{
    final InvalidationListener update = whatever ->
    {
        if (updating  ||  selected_action_index < 0)
            return;
        actions.set(selected_action_index, getWritePVAction());
    };

    final GridPane write_pv_details = new GridPane();
    write_pv_details.setHgap(10);
    write_pv_details.setVgap(10);

    write_pv_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    write_pv_description.textProperty().addListener(update);
    write_pv_details.add(write_pv_description, 1, 0);
    GridPane.setHgrow(write_pv_description, Priority.ALWAYS);

    write_pv_details.add(new Label(Messages.ActionsDialog_PVName), 0, 1);
    PVAutocompleteMenu.INSTANCE.attachField(write_pv_name);
    write_pv_name.textProperty().addListener(update);
    write_pv_details.add(write_pv_name, 1, 1);

    write_pv_details.add(new Label(Messages.ActionsDialog_Value), 0, 2);
    write_pv_value.textProperty().addListener(update);
    write_pv_details.add(write_pv_value, 1, 2);

    return write_pv_details;
}
 
Example 7
Source File: ImageChannelPreview.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void show() {
    super.show();

    if (redImage == null) {
        redImage = new WritableImage(120, 120);
        greenImage = new WritableImage(120, 120);
        blueImage = new WritableImage(120, 120);
        alphaImage = new WritableImage(120, 120);

        redView = new ImageView();
        greenView = new ImageView();
        blueView = new ImageView();
        alphaView = new ImageView();

        final GridPane root = getRoot();
        root.add(redView, 0, 0);
        root.add(greenView, 1, 0);
        root.add(blueView, 0, 1);
        root.add(alphaView, 1, 1);
    }

    if (isNeedToBuildFile()) {
        final Path file = getFile();
        buildPreview(file == null ? null : IMAGE_MANAGER.getImagePreview(file, 120, 120));
        setNeedToBuildFile(false);
    } else if (isNeedToBuildResource()) {
        final String resourcePath = getResourcePath();
        buildPreview(IMAGE_MANAGER.getImagePreview(resourcePath, 120, 120));
        setNeedToBuildResource(false);
    }
}
 
Example 8
Source File: UIAnalogMenuItem.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
@Override
protected int internalInitPanel(GridPane grid, int idx) {
    idx++;
    grid.add(new Label("Offset from zero"), 0, idx);
    offsetField = new TextField(String.valueOf(getMenuItem().getOffset()));
    offsetField.setId("offsetField");
    offsetField.textProperty().addListener(this::coreValueChanged);
    TextFormatterUtils.applyIntegerFormatToField(offsetField);
    grid.add(offsetField, 1, idx);

    idx++;
    grid.add(new Label("Maximum value"), 0, idx);
    maxValueField = new TextField(String.valueOf(getMenuItem().getMaxValue()));
    maxValueField.setId("maxValueField");
    maxValueField.textProperty().addListener(this::coreValueChanged);
    TextFormatterUtils.applyIntegerFormatToField(maxValueField);
    grid.add(maxValueField, 1, idx);

    idx++;
    grid.add(new Label("Divisor"), 0, idx);
    divisorField = new TextField(String.valueOf(getMenuItem().getDivisor()));
    divisorField.setId("divisorField");
    divisorField.textProperty().addListener(this::coreValueChanged);
    TextFormatterUtils.applyIntegerFormatToField(divisorField);
    grid.add(divisorField, 1, idx);

    idx++;
    grid.add(new Label("Unit name"), 0, idx);
    unitNameField = new TextField(getMenuItem().getUnitName());
    unitNameField.setId("unitNameField");
    unitNameField.textProperty().addListener(this::coreValueChanged);
    grid.add(unitNameField, 1, idx);

    return idx;
}
 
Example 9
Source File: LedController.java    From Sword_emulator with GNU General Public License v3.0 5 votes vote down vote up
public LedController(GridPane ledPane, Machine machine) {
    this.machine = machine;
    for (int i = 0; i < 16; i++) {
        circles[i] = new Circle(3);
        circles[i].setFill(Color.GRAY);
        ledPane.add(circles[i], i, 0);
    }
    TimingRenderer.register(this);
}
 
Example 10
Source File: PreferenceAppearencePane.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject
public PreferenceAppearencePane(@Named("localeCombo") PreferenceComboBox<LocaleKeyValueItem> localeCombo,
        @Named("startupModuleCombo") PreferenceComboBox<KeyStringValueItem<String>> startupModuleCombo,
        ClearStatisticsButton clearStatsButton) {
    I18nContext i18n = DefaultI18nContext.getInstance();
    add(new Label(i18n.i18n("Language:")), 0, 0);
    i18n.getSupportedLocales().stream().sorted(
            Comparator
            .comparing(Locale::getDisplayName))
            .map(LocaleKeyValueItem::new).forEach(localeCombo.getItems()::add);

    localeCombo.setValue(new LocaleKeyValueItem(Locale.getDefault()));
    localeCombo.valueProperty().addListener(
            (observable, oldValue, newValue) -> eventStudio().broadcast(new SetLocaleEvent(newValue.getKey())));
    localeCombo.setMaxWidth(Double.POSITIVE_INFINITY);
    setFillWidth(localeCombo, true);
    add(localeCombo, 1, 0);
    add(helpIcon(i18n.i18n("Set your preferred language (restart needed)")), 2, 0);

    add(new Label(i18n.i18n("Startup module:")), 0, 1);
    startupModuleCombo.setMaxWidth(Double.POSITIVE_INFINITY);
    setFillWidth(startupModuleCombo, true);
    add(startupModuleCombo, 1, 1);
    add(helpIcon(i18n.i18n("Set the module to open at application startup (restart needed)")), 2, 1);

    GridPane statsPane = new GridPane();
    statsPane.add(clearStatsButton, 0, 0);
    statsPane.add(
            helpIcon(i18n
                    .i18n("Usage statistics are used to populate the modules quick bar on the left with the most used and most recently used modules.")),
            1, 0);
    statsPane.getStyleClass().addAll(Style.GRID.css());
    add(statsPane, 0, 3, 3, 1);
    getStyleClass().addAll(Style.CONTAINER.css());
    getStyleClass().addAll(Style.GRID.css());
}
 
Example 11
Source File: SpectralMatchPanelFX.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private GridPane createTitlePane() {
  pnTitle = new GridPane();
  pnTitle.setAlignment(Pos.CENTER);

  // create Top panel
  double simScore = hit.getSimilarity().getScore();
  Color gradientCol = FxColorUtil.awtColorToFX(ColorScaleUtil
      .getColor(FxColorUtil.fxColorToAWT(MIN_COS_COLOR), FxColorUtil.fxColorToAWT(MAX_COS_COLOR),
          MIN_COS_COLOR_VALUE, MAX_COS_COLOR_VALUE, simScore));
  pnTitle.setBackground(
      new Background(new BackgroundFill(gradientCol, CornerRadii.EMPTY, Insets.EMPTY)));

  lblHit = new Label(hit.getName());
  lblHit.getStyleClass().add("white-larger-label");

  lblScore = new Label(COS_FORM.format(simScore));
  lblScore.getStyleClass().add("white-score-label");
  lblScore
      .setTooltip(new Tooltip("Cosine similarity of raw data scan (top, blue) and database scan: "
          + COS_FORM.format(simScore)));

  pnTitle.add(lblHit, 0, 0);
  pnTitle.add(lblScore, 1, 0);
  ColumnConstraints ccTitle0 = new ColumnConstraints(150, -1, -1, Priority.ALWAYS, HPos.LEFT,
      true);
  ColumnConstraints ccTitle1 = new ColumnConstraints(150, 150, 150, Priority.NEVER, HPos.LEFT,
      false);
  pnTitle.getColumnConstraints().add(0, ccTitle0);
  pnTitle.getColumnConstraints().add(1, ccTitle1);

  return pnTitle;
}
 
Example 12
Source File: Generator.java    From jsilhouette with Apache License 2.0 5 votes vote down vote up
private GridPane arrow(Stage stage) {
    stage.setTitle("Arrow");
    GridPane grid = grid();
    grid.add(new Arrow(0, 0, 100, 100).getShape(), 0, 0);
    grid.add(new Arrow(0, 0, 100, 100, 0.1, 0.5).getShape(), 1, 0);
    grid.add(new Arrow(0, 0, 100, 100, 0.5, 0.2).getShape(), 2, 0);
    return grid;
}
 
Example 13
Source File: RregulloPunen.java    From Automekanik with GNU General Public License v3.0 5 votes vote down vote up
public RregulloPunen(int id, ShikoPunetPunetoret spp, boolean kryer){
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    stage.setTitle("Rregullo");
    HBox btn = new HBox(5);
    btn.getChildren().addAll(btnOk, btnAnulo);
    btn.setAlignment(Pos.CENTER_RIGHT);
    GridPane grid = new GridPane();
    grid.add(cbKryer, 0, 0);
    grid.add(btn, 0, 1);
    grid.setVgap(10);
    grid.setAlignment(Pos.CENTER);

    cbKryer.setSelected(kryer);

    btnOk.setOnAction(e -> {
        azhurno(id);
        new Thread(new Runnable() {
            @Override
            public void run() {
                spp.mbushNgaStatusi(spp.lblEmri.getText());
            }
        }).start();
    });
    btnAnulo.setOnAction(e -> stage.close());

    Scene scene = new Scene(grid, 230, 100);
    scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
 
Example 14
Source File: DiffDisplayDialog.java    From zest-writer with GNU General Public License v3.0 4 votes vote down vote up
public DiffDisplayDialog(File file, String newContent, String titleContent, String titleExtract) {
	super(Configuration.getBundle().getString("ui.dialog.download.compare.window.title"), Configuration.getBundle().getString("ui.dialog.download.compare.window.header"));
	this.file = file;
	this.newContent = newContent;
	this.titleContent = titleContent;
       this.titleExtract = titleExtract;
       try {
           if(this.file.exists()) {
               this.oldContent = IOUtils.toString(new FileInputStream(this.file), "UTF-8");
           }
       } catch (IOException e) {
           log.error(e.getMessage(), e);
       }
       ;

    // Set the button types.
    ButtonType validButtonType = new ButtonType(Configuration.getBundle().getString("ui.dialog.download.compare.button.confirm"), ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(validButtonType, ButtonType.CANCEL);

	// Create the username and password labels and fields.
	GridPane grid = new GridPane();
	grid.setHgap(10);
	grid.setVgap(10);
	grid.setPadding(new Insets(20, 20, 10, 10));
       Label l01 = new Label(Configuration.getBundle().getString("ui.dialog.download.compare.content_name") + " : "+titleContent);
       Label l02 = new Label(Configuration.getBundle().getString("ui.dialog.download.compare.extract_name") + " : "+titleExtract);
	Label l1 = new Label(Configuration.getBundle().getString("ui.dialog.download.compare.old_content"));
       Label l2 = new Label(Configuration.getBundle().getString("ui.dialog.download.compare.new_content"));
	TextArea textArea1 = new TextArea();
	textArea1.setEditable(false);
       textArea1.setWrapText(true);
       textArea1.setPrefHeight(500);
       textArea1.setText(oldContent);
       ScrollPane scrollPane1 = new ScrollPane();
       scrollPane1.setContent(textArea1);
       scrollPane1.setFitToWidth(true);
	TextArea textArea2 = new TextArea();
       textArea2.setEditable(false);
       textArea2.setWrapText(true);
       textArea2.setPrefHeight(500);
       textArea2.setText(newContent);
       ScrollPane scrollPane2 = new ScrollPane();
       scrollPane2.setContent(textArea2);
       scrollPane2.setFitToWidth(true);


       grid.add(l01, 0, 0,2, 1);
       grid.add(l02, 0, 1, 2, 1);
	grid.add(l1, 0, 2);
    grid.add(l2, 1, 2);
       grid.add(scrollPane1, 0, 3);
       grid.add(scrollPane2, 1, 3);

    // Enable/Disable login button depending on whether a username was entered.
	this.getDialogPane().lookupButton(validButtonType);

	this.getDialogPane().setContent(grid);

	Platform.runLater(textArea1::requestFocus);

	this.setResultConverter(dialogButton -> {
		if(dialogButton == validButtonType) {
               return true;
		}
		return false;
	});
}
 
Example 15
Source File: ActionsDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** @return Sub-pane for OpenDisplay action */
private GridPane createOpenDisplayDetails()
{
    final InvalidationListener update = whatever ->
    {
        if (updating  ||  selected_action_index < 0)
            return;
        actions.set(selected_action_index, getOpenDisplayAction());
    };

    final GridPane open_display_details = new GridPane();
    // open_display_details.setGridLinesVisible(true);
    open_display_details.setHgap(10);
    open_display_details.setVgap(10);

    open_display_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    open_display_description.textProperty().addListener(update);
    open_display_details.add(open_display_description, 1, 0);
    GridPane.setHgrow(open_display_description, Priority.ALWAYS);

    open_display_details.add(new Label(Messages.ActionsDialog_DisplayPath), 0, 1);
    open_display_path.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event ->
    {
        try
        {
            final String path = FilenameSupport.promptForRelativePath(widget, open_display_path.getText());
            if (path != null)
                open_display_path.setText(path);
            FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot prompt for filename", ex);
        }
    });
    final HBox path_box = new HBox(open_display_path, select);
    HBox.setHgrow(open_display_path, Priority.ALWAYS);
    open_display_details.add(path_box, 1, 1);

    final HBox modes_box = new HBox(10);
    open_display_targets = new ToggleGroup();
    final Target[] modes = Target.values();
    for (int i=0; i<modes.length; ++i)
    {
        // Suppress deprecated legacy mode which is handled as WINDOW
        if (modes[i] == Target.STANDALONE)
            continue;

        final RadioButton target = new RadioButton(modes[i].toString());
        target.setToggleGroup(open_display_targets);
        target.selectedProperty().addListener(update);
        modes_box.getChildren().add(target);

        if (modes[i] == Target.TAB)
            open_display_pane.disableProperty().bind(target.selectedProperty().not());
    }
    open_display_pane.textProperty().addListener(update);
    open_display_details.add(modes_box, 0, 2, 2, 1);

    open_display_details.add(new Label("Pane:"), 0, 3);
    open_display_details.add(open_display_pane, 1, 3);

    open_display_macros = new MacrosTable(new Macros());
    open_display_macros.addListener(update);
    open_display_details.add(open_display_macros.getNode(), 0, 4, 2, 1);
    GridPane.setHgrow(open_display_macros.getNode(), Priority.ALWAYS);
    GridPane.setVgrow(open_display_macros.getNode(), Priority.ALWAYS);

    return open_display_details;
}
 
Example 16
Source File: Demo.java    From Medusa with Apache License 2.0 4 votes vote down vote up
@Override public void start(Stage stage) {
    GridPane pane = new GridPane();
    pane.add(gauge1, 0, 0);
    pane.add(gauge2, 1, 0);
    pane.add(gauge3, 2, 0);
    pane.add(gauge4, 3, 0);
    pane.add(gauge5, 4, 0);
    pane.add(clock1, 5, 0);
    pane.add(clock5, 6, 0);
    pane.add(gauge22, 7, 0);
    pane.add(gauge29, 8, 0);

    pane.add(gauge6, 0, 1);
    pane.add(gauge7, 1, 1);
    pane.add(gauge8, 2, 1);
    pane.add(gauge9, 3, 1);
    pane.add(gauge10, 4, 1);
    pane.add(clock2, 5, 1);
    pane.add(gauge21, 6, 1);
    pane.add(gauge23, 7, 1);
    pane.add(gauge30, 8, 1);

    pane.add(gauge11, 0, 2);
    pane.add(gauge12, 1, 2);
    pane.add(gauge13, 2, 2);
    pane.add(gauge14, 3, 2);
    pane.add(gauge15, 4, 2);
    pane.add(clock3, 5, 2);
    pane.add(clock6, 6, 2);
    pane.add(clock8, 7, 2);
    pane.add(gauge31, 8, 2);

    pane.add(gauge16, 0, 3);
    pane.add(gauge17, 1, 3);
    pane.add(gauge18, 2, 3);
    pane.add(gauge19, 3, 3);
    pane.add(gauge20, 4, 3);
    pane.add(clock4, 5, 3);
    pane.add(clock7, 6, 3);
    pane.add(gauge24, 7, 3);
    pane.add(clock12, 8, 3);

    pane.add(gauge25, 0, 4);
    pane.add(gauge26, 1, 4);
    pane.add(gauge27, 2, 4);
    pane.add(gauge28, 4, 4);
    pane.add(clock9, 5, 4);
    pane.add(clock10, 6, 4);
    pane.add(clock11, 7, 4);
    pane.setHgap(10);
    pane.setVgap(10);
    pane.setPadding(new Insets(10));
    for (int i = 0 ; i < 9 ; i++) {
        pane.getColumnConstraints().add(new ColumnConstraints(MIN_CELL_SIZE, PREF_CELL_SIZE, MAX_CELL_SIZE));
    }
    for (int i = 0 ; i < 5 ; i++) {
        pane.getRowConstraints().add(new RowConstraints(MIN_CELL_SIZE, PREF_CELL_SIZE, MAX_CELL_SIZE));
    }
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(90, 90, 90), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("Medusa Gauges and Clocks");
    stage.setScene(scene);
    stage.show();

    timer.start();

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 17
Source File: PortsItemEventHandler.java    From EWItool with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void handle( ActionEvent arg0 ) {
  
  Dialog<ButtonType> dialog = new Dialog<>();
  dialog.setTitle( "EWItool - Select MIDI Ports" );
  dialog.getDialogPane().getButtonTypes().addAll( ButtonType.CANCEL, ButtonType.OK );
  GridPane gp = new GridPane();
  
  gp.add( new Label( "MIDI In Ports" ), 0, 0 );
  gp.add( new Label( "MIDI Out Ports" ), 1, 0 );
  
  ListView<String> inView, outView;
  List<String> inPortList = new ArrayList<>(),
               outPortList = new ArrayList<>();
  ObservableList<String> inPorts = FXCollections.observableArrayList( inPortList ), 
                         outPorts = FXCollections.observableArrayList( outPortList );
  inView = new ListView<>( inPorts );
  outView = new ListView<>( outPorts );
     
  String lastInDevice = userPrefs.getMidiInPort();
  String lastOutDevice = userPrefs.getMidiOutPort();
  int ipIx = -1, opIx = -1;
  
  MidiDevice device;
  MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
  for ( MidiDevice.Info info : infos ) {
    try {
      device = MidiSystem.getMidiDevice( info );
      if (!( device instanceof Sequencer ) && !( device instanceof Synthesizer )) {
        if (device.getMaxReceivers() != 0) {
          opIx++;
          outPorts.add( info.getName() );
          if (info.getName().equals( lastOutDevice )) {
            outView.getSelectionModel().clearAndSelect( opIx );
          }
          Debugger.log( "DEBUG - Found OUT Port: " + info.getName() + " - " + info.getDescription() );
        } else if (device.getMaxTransmitters() != 0) {
          ipIx++;
          inPorts.add( info.getName() );
          if (info.getName().equals( lastInDevice )) {
            inView.getSelectionModel().clearAndSelect( ipIx );
          }
          Debugger.log( "DEBUG - Found IN Port: " + info.getName() + " - " + info.getDescription() );
        }
      }
    } catch (MidiUnavailableException ex) {
      ex.printStackTrace();
    }
  }
 
  gp.add( inView, 0, 1 );
  gp.add( outView, 1, 1 );
  dialog.getDialogPane().setContent( gp );
  
  Optional<ButtonType> rc = dialog.showAndWait();
  
  if (rc.get() == ButtonType.OK) {
    if (outView.getSelectionModel().getSelectedIndex() != -1) {
      userPrefs.setMidiOutPort( outView.getSelectionModel().getSelectedItem() );
    }
    if (inView.getSelectionModel().getSelectedIndex() != -1) {
      userPrefs.setMidiInPort( inView.getSelectionModel().getSelectedItem() );
    } 
  }
}
 
Example 18
Source File: PasswordDialogController.java    From chvote-1-0 with GNU Affero General Public License v3.0 4 votes vote down vote up
private void openPasswordInputDialog(StringProperty target, int groupNumber, boolean withConfirmation) throws ProcessInterruptedException {
    Dialog<String> dialog = new Dialog<>();
    String title = String.format(resources.getString("password_dialog.title"), groupNumber);
    dialog.setTitle(title);
    dialog.getDialogPane().getStylesheets().add("/ch/ge/ve/offlineadmin/styles/offlineadmin.css");
    dialog.getDialogPane().getStyleClass().addAll("background", "password-dialog");

    // Define and add buttons
    ButtonType confirmPasswordButtonType = new ButtonType(resources.getString("password_dialog.confirm_button"), ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(confirmPasswordButtonType, ButtonType.CANCEL);

    // Create header label
    Label headerLabel = new Label(title);
    headerLabel.getStyleClass().add("header-label");

    // Create the input labels and fields
    GridPane grid = new GridPane();
    grid.setHgap(GRID_GAP);
    grid.setVgap(GRID_GAP);
    grid.setPadding(GRID_INSETS);

    TextField electionOfficer1Password = new TextField();
    String electionOfficer1Label = withConfirmation ? resources.getString("password_dialog.election_officer_1")
            : resources.getString("password_dialog.election_officer");
    electionOfficer1Password.setPromptText(electionOfficer1Label);
    electionOfficer1Password.setId("passwordField1");

    TextField electionOfficer2Password = new TextField();
    String electionOfficer2Label = resources.getString("password_dialog.election_officer_2");
    electionOfficer2Password.setPromptText(electionOfficer2Label);
    electionOfficer2Password.setId("passwordField2");

    // Create error message label
    Label errorMessage = createErrorMessage(withConfirmation);
    errorMessage.setId("errorLabel");

    // Position the labels and fields
    int row = 0;
    grid.add(headerLabel, LABEL_COL, row, 2, 1);
    row++;
    grid.add(new Label(electionOfficer1Label), LABEL_COL, row);
    grid.add(electionOfficer1Password, INPUT_COL, row);
    if (withConfirmation) {
        row++;
        grid.add(new Label(electionOfficer2Label), LABEL_COL, row);
        grid.add(electionOfficer2Password, INPUT_COL, row);
    }
    row++;
    grid.add(errorMessage, LABEL_COL, row, 2, 1);

    dialog.getDialogPane().setContent(grid);

    // Perform input validation
    Node confirmButton = dialog.getDialogPane().lookupButton(confirmPasswordButtonType);
    confirmButton.setDisable(true);

    BooleanBinding booleanBinding = bindForValidity(withConfirmation, electionOfficer1Password, electionOfficer2Password, errorMessage, confirmButton);

    // Convert the result
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == confirmPasswordButtonType) {
            return electionOfficer1Password.textProperty().getValueSafe();
        } else {
            return null;
        }
    });

    Platform.runLater(electionOfficer1Password::requestFocus);

    Optional<String> result = dialog.showAndWait();

    //if not disposed then we do have binding errors if this method is run again
    booleanBinding.dispose();
    result.ifPresent(target::setValue);

    if (!result.isPresent()) {
        throw new ProcessInterruptedException("Password input cancelled");
    }
}
 
Example 19
Source File: AdjustbodyMassWidget.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
public AdjustbodyMassWidget(MobileBase device) {
	this.device = device;
	manager = MobileBaseCadManager.get(device);
	GridPane pane = new GridPane();
	
	TextField mass = new TextField(CreatureLab.getFormatted(device.getMassKg()));
	mass.setOnAction(event -> {
		device.setMassKg(textToNum(mass));
		if(manager!=null)manager.generateCad();
	});
	TransformNR currentCentroid = device.getCenterOfMassFromCentroid();
	TextField massx = new TextField(CreatureLab.getFormatted(currentCentroid.getX()));
	massx.setOnAction(event -> {
		currentCentroid.setX(textToNum(massx));
		device.setCenterOfMassFromCentroid(currentCentroid);
		;
		if(manager!=null)manager.generateCad();

	});

	TextField massy = new TextField(CreatureLab.getFormatted(currentCentroid.getY()));
	massy.setOnAction(event -> {
		currentCentroid.setY(textToNum(massy));
		device.setCenterOfMassFromCentroid(currentCentroid);
		;
		if(manager!=null)manager.generateCad();

	});

	TextField massz = new TextField(CreatureLab.getFormatted(currentCentroid.getZ()));
	massz.setOnAction(event -> {
		currentCentroid.setZ(textToNum(massz));
		device.setCenterOfMassFromCentroid(currentCentroid);
		;
		if(manager!=null)manager.generateCad();

	});
	
	
	
	pane.add(new Text("Mass"), 0, 0);
	pane.add(mass, 1, 0);

	pane.add(new Text("Mass Centroid x"), 0, 1);
	pane.add(massx, 1, 1);

	pane.add(new Text("Mass Centroid y"), 0, 2);
	pane.add(massy, 1, 2);
	pane.add(new Text("Mass Centroid z"), 0, 3);
	pane.add(massz, 1,3);
	getChildren().add(pane);
}
 
Example 20
Source File: Exercise_16_23.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	final int COLUMN_COUNT = 27;
	tfSpeed.setPrefColumnCount(COLUMN_COUNT);
	tfPrefix.setPrefColumnCount(COLUMN_COUNT);
	tfNumberOfImages.setPrefColumnCount(COLUMN_COUNT);
	tfURL.setPrefColumnCount(COLUMN_COUNT);

	// Create a button
	Button btStart = new Button("Start Animation");

	// Create a grid pane for labels and text fields
	GridPane paneForInfo = new GridPane();
	paneForInfo.setAlignment(Pos.CENTER);
	paneForInfo.add(new Label("Enter information for animation"), 0, 0);
	paneForInfo.add(new Label("Animation speed in milliseconds"), 0, 1);
	paneForInfo.add(tfSpeed, 1, 1);
	paneForInfo.add(new Label("Image file prefix"), 0, 2);
	paneForInfo.add(tfPrefix, 1, 2);
	paneForInfo.add(new Label("Number of images"), 0, 3);
	paneForInfo.add(tfNumberOfImages, 1, 3);
	paneForInfo.add(new Label("Audio file URL"), 0, 4);
	paneForInfo.add(tfURL, 1, 4);


	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setBottom(paneForInfo);
	pane.setCenter(paneForImage);
	pane.setTop(btStart);
	pane.setAlignment(btStart, Pos.TOP_RIGHT);

	// Create animation
	animation = new Timeline(
		new KeyFrame(Duration.millis(1000), e -> nextImage()));
	animation.setCycleCount(Timeline.INDEFINITE);

	// Create and register the handler
	btStart.setOnAction(e -> {
		if (tfURL.getText().length() > 0) {
			MediaPlayer mediaPlayer = new MediaPlayer(
				new Media(tfURL.getText()));
			mediaPlayer.play();
		}
		if (tfSpeed.getText().length() > 0)
			animation.setRate(Integer.parseInt(tfSpeed.getText()));
		animation.play();
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 550, 680);
	primaryStage.setTitle("Exercise_16_23"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}