Java Code Examples for javafx.scene.control.Button#setDisable()

The following examples show how to use javafx.scene.control.Button#setDisable() . 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: WizardStageDialog.java    From arma-dialog-creator with MIT License 9 votes vote down vote up
public WizardStageDialog(@Nullable Stage primaryStage, @Nullable String title, boolean hasHelp, @NotNull WizardStep... wizardSteps) {
	super(primaryStage, new StackPane(), title, true, true, hasHelp);


	wizardStepsReadOnly = new ReadOnlyList<>(wizardSteps);

	btnPrevious = new Button(Lang.ApplicationBundle().getString("Wizards.previous"));
	btnPrevious.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			goBackwardStep();
		}
	});

	btnPrevious.setPrefWidth(GenericResponseFooter.PREFFERED_BUTTON_OK_WIDTH);
	footer.getRightContainer().getChildren().add(1, btnPrevious);
	footer.btnOk.setText(Lang.ApplicationBundle().getString("Wizards.next"));

	Collections.addAll(this.wizardSteps, wizardSteps);

	for (WizardStep step : wizardSteps) {
		addWizardStep(step);
	}
	btnPrevious.setDisable(true);
}
 
Example 2
Source File: BasicView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void updateAppBar(AppBar appBar) {

    Button removeButton = MaterialDesignIcon.DELETE.button(this::removeSelected);
    removeButton.setDisable(true);

    selectedShapeProperty.addListener( (o, oldShape, newShape) -> {
        updateShapeAppearance( oldShape, false );
        updateShapeAppearance( newShape, true );
        removeButton.setDisable( newShape == null );
    });

    appBar.setTitleText("Reactive Sample");
    appBar.getActionItems().add(MaterialDesignIcon.ADD_BOX.button(this::addBox) );
    appBar.getActionItems().add(MaterialDesignIcon.ADD_CIRCLE.button(this::addCircle));
    appBar.getActionItems().add(removeButton);
    appBar.getActionItems().add(MaterialDesignIcon.CLEAR_ALL.button(this::clearAllShapes));
}
 
Example 3
Source File: MainframeStage.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
private void enableButtons (boolean enable)
{
  for (Button button : buttons)
    button.setDisable (!enable);

  btnReadBuffer.setDisable (!enable);
  btnReadModified.setDisable (!enable);
  btnReadModifiedAll.setDisable (!enable);
  btnEraseAllUnprotected.setDisable (!enable);
  btnProgramTab1.setDisable (!enable);
  btnProgramTab2.setDisable (!enable);
  btnProgramTab3.setDisable (!enable);

  btnFieldMode.setDisable (!enable);
  btnExtendedFieldMode.setDisable (!enable);
  btnCharacterMode.setDisable (!enable);

  toFront ();
  buttons.get (3).fire ();          // ISPF (Erase Write)
  buttons.get (4).fire ();          // 3.4  (Write)
  this.requestFocus ();
  buttons.get (4).requestFocus ();
}
 
Example 4
Source File: NodeSelectorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
public NodeSelectorDialog(@NotNull final Spatial model, @NotNull final Class<T> type,
                          @NotNull final Consumer<T> handler) {
    this.model = model;
    this.type = type;
    this.handler = handler;

    final ModelNodeTree nodeTree = getNodeTree();
    nodeTree.fill(getModel());
    nodeTree.getTreeView().setEditable(false);

    final Button okButton = notNull(getOkButton());
    okButton.setDisable(true);
}
 
Example 5
Source File: NodeSelectorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle the selected objects.
 */
@FxThread
private void processSelect(@Nullable final Array<Object> objects) {
    final Object object = objects.first();
    final Object result = object instanceof TreeNode ? ((TreeNode) object).getElement() : object;
    final Class<T> type = getType();
    final Button okButton = notNull(getOkButton());
    okButton.setDisable(!type.isInstance(result));
    selected = type.isInstance(result) ? type.cast(result) : null;
}
 
Example 6
Source File: ExternalFileEditorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle selected element in the tree.
 */
@FxThread
private void processSelected(@Nullable final TreeItem<ResourceElement> newValue) {
    final ResourceElement element = newValue == null ? null : newValue.getValue();
    final Path file = element == null ? null : element.getFile();
    final Button okButton = notNull(getOkButton());
    okButton.setDisable(file == null || !Files.isWritable(file));
}
 
Example 7
Source File: NavigatorPanel.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public VLToolBar createToolbar(ResourceView resourceView) {
    VLToolBar toolbar = new VLToolBar();
    Button expandAll = FXUIUtils.createButton("expandAll", "Expand the resource tree");
    expandAll.setOnAction((event) -> resourceView.expandAll());
    toolbar.add(expandAll);
    Button collapseAll = FXUIUtils.createButton("collapseAll", "Collapse the resource tree");
    collapseAll.setOnAction((event) -> resourceView.collapseAll());
    toolbar.add(collapseAll);
    toolbar.add(new Separator(javafx.geometry.Orientation.VERTICAL));
    Button cut = FXUIUtils.createButton("cut", "Cut the selected content to clipboard");
    cut.setOnAction((event) -> resourceView.cut());
    toolbar.add(cut);
    Button copy = FXUIUtils.createButton("copy", "Copy the selected content to clipboard");
    copy.setOnAction((event) -> resourceView.copy());
    toolbar.add(copy);
    Button paste = FXUIUtils.createButton("paste", "Paste clipboard contents");
    paste.setOnAction((event) -> resourceView.paste());
    toolbar.add(paste);
    ListChangeListener<? super TreeItem<Resource>> listener = new ListChangeListener<TreeItem<Resource>>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<Resource>> c) {
            cut.setDisable(resourceView.getSelectionModel().getSelectedItems().size() <= 0);
            copy.setDisable(resourceView.getSelectionModel().getSelectedItems().size() <= 0);
            paste.setDisable(resourceView.getSelectionModel().getSelectedItems().size() != 1);
        }
    };
    resourceView.getSelectionModel().getSelectedItems().addListener(listener);
    return toolbar;
}
 
Example 8
Source File: AbstractSimpleAction.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void setEnabled(boolean b) {
    for (Button button : buttons) {
        button.setDisable(!b);
    }
    for (MenuItem menuItem : menuItems) {
        menuItem.setDisable(!b);
    }
}
 
Example 9
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Button getButton(String name, VBox vbox, int width)
{
  Button button = new Button(name);
  button.setPrefWidth(width);
  vbox.getChildren().add(button);
  button.setDisable(true);
  return button;
}
 
Example 10
Source File: ParameterSetupDialog.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void setupHelpButton(URL helpURL) {

    // Add a Help button
    ButtonType helpButtonType = new ButtonType("Help", ButtonData.HELP);
    getDialogPane().getButtonTypes().add(helpButtonType);
    Button helpButton = (Button) getDialogPane().lookupButton(helpButtonType);

    // If there is no help file, disable the Help button
    if (helpURL == null) {
      helpButton.setDisable(true);
      return;
    }

    // Prevent closing this dialog by the Help button by adding an event
    // filter
    helpButton.addEventFilter(ActionEvent.ACTION, event -> {
      if ((helpWindow != null) && (!helpWindow.isShowing())) {
        helpWindow = null;
      }

      if (helpWindow != null) {
        helpWindow.toFront();
      } else {
        helpWindow = new HelpWindow(helpURL.toString());
        helpWindow.show();
      }
      event.consume();
    });

    // Close the help window when we close this dialog
    setOnHidden(e -> {
      if ((helpWindow != null) && (helpWindow.isShowing())) {
        helpWindow.close();
      }
    });

  }
 
Example 11
Source File: DisplayUpdateDownloadWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showErrorMessage(Button downloadButton, Label statusLabel, String errorMsg) {
    statusLabel.setText("");
    stopAnimations();
    downloadButton.setDisable(false);
    new Popup()
            .headLine(Res.get("displayUpdateDownloadWindow.download.failed.headline"))
            .feedback(errorMsg)
            .onClose(this::doClose)
            .show();
}
 
Example 12
Source File: SceneSelectorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
public SceneSelectorDialog(@NotNull final SceneNode sceneNode, @NotNull final Class<T> type,
                           @NotNull final Consumer<T> handler) {
    this.sceneNode = sceneNode;
    this.type = type;
    this.handler = handler;

    final SceneNodeTree nodeTree = getNodeTree();
    nodeTree.fill(getSceneNode());
    nodeTree.getTreeView().setEditable(false);

    final Button okButton = notNull(getOkButton());
    okButton.setDisable(true);
}
 
Example 13
Source File: SceneSelectorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle the selected object.
 */
@FxThread
private void processSelect(@Nullable final Object object) {
    final Object result = object instanceof TreeNode ? ((TreeNode) object).getElement() : object;
    final Class<T> type = getType();
    final Button okButton = notNull(getOkButton());
    okButton.setDisable(!type.isInstance(result));
    selected = type.isInstance(result) ? type.cast(result) : null;
}
 
Example 14
Source File: GenerateLodLevelsDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Update disabling of OK button.
 */
@FxThread
private void updateButtonOk() {

    final ListView<Number> levelsList = getLevelsList();
    final ObservableList<Number> items = levelsList.getItems();

    final Button okButton = getOkButton();
    okButton.setDisable(items.isEmpty());
}
 
Example 15
Source File: HelloWebView.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void start(Stage stage) {
        List<String> args = getParameters().getRaw();
        final String initialURL = args.size() > 0 ? args.get(0) : DEFAULT_URL;

        final WebView webView = new WebView();
    	final WebEngine webEngine = webView.getEngine();

        final TextField urlBox = new TextField();
        urlBox.setMinHeight(NAVI_BAR_MIN_DIMENSION);

        urlBox.setText(initialURL);
        HBox.setHgrow(urlBox, Priority.ALWAYS);
        urlBox.setOnAction(e -> webEngine.load(urlBox.getText()));

//-        Button goButton = new Button("Go");
//-        goButton.setOnAction(e -> webEngine.load(urlBox.getText()));
        final Label bottomTitle = new Label();
        bottomTitle.textProperty().bind(urlBox.textProperty());

//-        HBox naviBar = new HBox();
//-        naviBar.getChildren().addAll(urlBox, goButton);
        final Button goStopButton = new Button(goButtonUnicodeSymbol);
        goStopButton.setStyle(buttonStyle);
        goStopButton.setOnAction(e -> webEngine.load(urlBox.getText()));

//-        BorderPane root = new BorderPane();
//-        root.setTop(naviBar);
//-        root.setCenter(webView);
        final Button backButton = new Button(backButtonUnicodeSymbol);
        backButton.setStyle(buttonStyle);
        backButton.setDisable(true);
        backButton.setOnAction(e -> webEngine.getHistory().go(-1));

//-        webEngine.locationProperty().addListener((obs, oVal, nVal)
//-                -> urlBox.setText(nVal));
        final Button forwardButton = new Button(forwardButtonUnicodeSymbol);
        forwardButton.setStyle(buttonStyle);
        forwardButton.setDisable(true);
        forwardButton.setOnAction(e -> webEngine.getHistory().go(+1));

        final Button reloadButton = new Button(reloadButtonUnicodeSymbol);
        reloadButton.setStyle(buttonStyle);
        reloadButton.setOnAction(e -> webEngine.reload());

        final HBox naviBar = new HBox();
        naviBar.getChildren().addAll(backButton, forwardButton, urlBox,
                reloadButton, goStopButton);
        naviBar.setPadding(new Insets(PADDING_VALUE)); // Small padding in the navigation Bar

        final VBox root = new VBox();
        root.getChildren().addAll(naviBar, webView, bottomTitle);
        VBox.setVgrow(webView, Priority.ALWAYS);

        webEngine.locationProperty().addListener((observable, oldValue, newValue) ->
                urlBox.setText(newValue));

        // If the Worker.State is in lower State than SUCCEEDED (i.e. in READY, SCHEDULED or RUNNING State),
        // then the goStopButton should be in 'Stop' configuration
        // else the goStopButton should be in 'Go' configuration
        webEngine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
            if (newValue.compareTo(Worker.State.SUCCEEDED) < 0) {
                bottomTitle.setVisible(true);
                goStopButton.setText(stopButtonUnicodeSymbol);
                goStopButton.setOnAction(e -> webEngine.getLoadWorker().cancel());
            } else {
                bottomTitle.setVisible(false);
                goStopButton.setText(goButtonUnicodeSymbol);
                goStopButton.setOnAction(e -> webEngine.load(urlBox.getText()));
            }
        });

        webEngine.getHistory().currentIndexProperty().addListener((observable, oldValue, newValue) -> {
            int length = webEngine.getHistory().getEntries().size();

            backButton.setDisable((int)newValue == 0);
            forwardButton.setDisable((int)newValue >= length - 1);
        });

        webEngine.load(initialURL);

        Scene scene = new Scene(root);
        stage.setScene(scene);

//-        SimpleStringProperty titleProp = new SimpleStringProperty("HelloWebView: ");
        SimpleStringProperty titleProp = new SimpleStringProperty("HelloWebView" +
                " (" + System.getProperty("java.version") + ") : ");
        stage.titleProperty().bind(titleProp.concat(urlBox.textProperty()));
        stage.show();
    }
 
Example 16
Source File: CreateSkyDialog.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
/**
 * Validate the dialog.
 */
@FxThread
private void validate() {
    if (!isReady()) return;

    final ComboBox<SkyType> skyTypeComboBox = getSkyTypeComboBox();
    final SingleSelectionModel<SkyType> selectionModel = skyTypeComboBox.getSelectionModel();
    final SkyType selectedItem = selectionModel.getSelectedItem();

    final Button okButton = getOkButton();
    okButton.setDisable(true);

    if (isEditableSky()) {

        final ChooseFolderControl materialFolderControl = getMaterialFolderControl();
        final TextField materialNameField = getMaterialNameField();

        final boolean valid = materialFolderControl.getFolder() != null &&
                !StringUtils.isEmpty(materialNameField.getText());

        if (!valid) {
            okButton.setDisable(true);
            return;
        }
    }

    if (selectedItem == SkyType.SINGLE_TEXTURE) {

        final ComboBox<EnvMapType> envMapTypeComboBox = getEnvMapTypeComboBox();
        final EnvMapType envMapType = envMapTypeComboBox.getSelectionModel().getSelectedItem();

        final ChooseTextureControl singleTextureControl = getSingleTextureControl();
        final Path textureFile = singleTextureControl.getTextureFile();

        okButton.setDisable(envMapType == null || textureFile == null);

    } else if (selectedItem == SkyType.MULTIPLE_TEXTURE) {

        final ChooseTextureControl northTextureControl = getNorthTextureControl();
        final Path northTextureFile = northTextureControl.getTextureFile();

        final ChooseTextureControl southTextureControl = getSouthTextureControl();
        final Path southTextureFile = southTextureControl.getTextureFile();

        final ChooseTextureControl eastTextureControl = getEastTextureControl();
        final Path eastTextureFile = eastTextureControl.getTextureFile();

        final ChooseTextureControl westTextureControl = getWestTextureControl();
        final Path westTextureFile = westTextureControl.getTextureFile();

        final ChooseTextureControl topTextureControl = getTopTextureControl();
        final Path topTextureFile = topTextureControl.getTextureFile();

        final ChooseTextureControl bottomTextureControl = getBottomTextureControl();
        final Path bottomTextureFile = bottomTextureControl.getTextureFile();

        if (northTextureFile == null || southTextureFile == null) {
            okButton.setDisable(true);
        } else if (eastTextureFile == null || westTextureFile == null) {
            okButton.setDisable(true);
        } else if (topTextureFile == null || bottomTextureFile == null) {
            okButton.setDisable(true);
        } else {
            okButton.setDisable(false);
        }
    }
}
 
Example 17
Source File: TrainingPane.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
private void exportGraph(Button source, int checkpoint) {
    save();
    TFTrainer.exportGraph(checkpoint);
    AppUtils.showInformation(bundle.getString("label.alert"), MessageFormat.format(bundle.getString("msg.exportGraph"), checkpoint));
    source.setDisable(true);
}
 
Example 18
Source File: ListLayout.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void setButtonState(Button button, boolean enable) {
    if (button != null) {
        button.setDisable(!enable);
    }
}
 
Example 19
Source File: MainApp.java    From GMapsFX with Apache License 2.0 4 votes vote down vote up
@Override
  public void start(final Stage stage) throws Exception {
      System.out.println("Java version: " + System.getProperty("java.home"));
      mapComponent = new GoogleMapView(Locale.getDefault().getLanguage(), null);
      mapComponent.addMapInitializedListener(this);
              
      BorderPane bp = new BorderPane();
      ToolBar tb = new ToolBar();

      btnZoomIn = new Button("Zoom In");
      btnZoomIn.setOnAction(e -> {
          map.zoomProperty().set(map.getZoom() + 1);
      });
      btnZoomIn.setDisable(true);

      btnZoomOut = new Button("Zoom Out");
      btnZoomOut.setOnAction(e -> {
          map.zoomProperty().set(map.getZoom() - 1);
      });
      btnZoomOut.setDisable(true);

      lblZoom = new Label();
      lblCenter = new Label();
      lblClick = new Label();
      
      mapTypeCombo = new ComboBox<>();
      mapTypeCombo.setOnAction( e -> {
         map.setMapType(mapTypeCombo.getSelectionModel().getSelectedItem() );
      });
      mapTypeCombo.setDisable(true);
      
      Button btnType = new Button("Map type");
      btnType.setOnAction(e -> {
          map.setMapType(MapTypeIdEnum.HYBRID);
      });

btnHideMarker = new Button("Hide Marker");
btnHideMarker.setOnAction(e -> {hideMarker();});

btnDeleteMarker = new Button("Delete Marker");
btnDeleteMarker.setOnAction(e -> {deleteMarker();});

      tb.getItems().addAll(btnZoomIn, btnZoomOut, mapTypeCombo,
              new Label("Zoom: "), lblZoom,
              new Label("Center: "), lblCenter,
              new Label("Click: "), lblClick,
		btnHideMarker, btnDeleteMarker);

      bp.setTop(tb);
      
      bp.setCenter(mapComponent);

      Scene scene = new Scene(bp);
      stage.setScene(scene);
      stage.show();
  }
 
Example 20
Source File: PCGenToolBar.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ToolBar buildMenu()
{
	ToolBar toolBar = new ToolBar();

	Button newButton = new Button();
	newButton.setOnAction(this::onNew);
	newButton.setGraphic(new ImageView(Icons.New16.asJavaFX()));
	newButton.setText(LanguageBundle.getString("in_mnuFileNew"));
	newButton.setDisable(true);
	ReferenceFacade<DataSetFacade> loadedDataSetRef = rootFrame.getLoadedDataSetRef();
	loadedDataSetRef.addReferenceListener(new EnabledOnlyWithSources(newButton, rootFrame));
	toolBar.getItems().add(newButton);

	Button openButton = new Button();
	openButton.setOnAction(this::onOpen);
	openButton.setGraphic(new ImageView(Icons.Open16.asJavaFX()));
	openButton.setText(LanguageBundle.getString("in_mnuFileOpen"));
	toolBar.getItems().add(openButton);

	Button closeButton = new Button();
	closeButton.setOnAction(this::onClose);
	closeButton.setGraphic(new ImageView(Icons.Close16.asJavaFX()));
	closeButton.setText (LanguageBundle.getString("in_mnuFileClose"));
	toolBar.getItems().add(closeButton);
	ReferenceFacade<CharacterFacade> ref = rootFrame.getSelectedCharacterRef();
	ref.addReferenceListener(new EnabledOnlyWithCharacter(closeButton, rootFrame));

	Button saveButton = new Button();
	saveButton.setOnAction(this::onSave);
	saveButton.setGraphic(new ImageView(Icons.Save16.asJavaFX()));
	saveButton.setText(LanguageBundle.getString("in_mnuFileSave"));
	toolBar.getItems().add(saveButton);
	ref.addReferenceListener(new EnabledOnlyWithCharacter(saveButton, rootFrame));

	Button printButton = new Button();
	printButton.setOnAction(this::onPrint);
	printButton.setGraphic(new ImageView(Icons.Print16.asJavaFX()));
	printButton.setText(LanguageBundle.getString("in_mnuFilePrint"));
	toolBar.getItems().add(printButton);
	ref.addReferenceListener(new EnabledOnlyWithCharacter(printButton, rootFrame));

	Button exportButton = new Button();
	exportButton.setOnAction(this::onExport);
	exportButton.setGraphic(new ImageView(Icons.Export16.asJavaFX()));
	exportButton.setText(LanguageBundle.getString("in_mnuFileExport"));
	toolBar.getItems().add(exportButton);
	ref.addReferenceListener(new EnabledOnlyWithCharacter(exportButton, rootFrame));

	Button preferencesButton = new Button();
	preferencesButton.setOnAction(this::onPreferences);
	preferencesButton.setGraphic(new ImageView(Icons.Preferences16.asJavaFX()));
	preferencesButton.setText(LanguageBundle.getString("in_mnuToolsPreferences"));
	toolBar.getItems().add(preferencesButton);

	return toolBar;
}