Example usage for javafx.scene.control Button setTooltip

List of usage examples for javafx.scene.control Button setTooltip

Introduction

In this page you can find the example usage for javafx.scene.control Button setTooltip.

Prototype

public final void setTooltip(Tooltip value) 

Source Link

Usage

From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java

private void initializeFilesTree() {
    folderTree.setOnMouseClicked(event -> handleFolderChange());
    folderTree.setCellFactory(treeView -> {
        HBox hbox = new HBox();
        hbox.setMaxWidth(200);/*from  w w w  .  j av  a 2 s.  c  om*/
        hbox.setPrefWidth(200);
        hbox.setSpacing(7);

        FontAwesomeIconView openFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN_ALT);
        openFolderIcon.setTranslateY(7);
        FontAwesomeIconView closedFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT);
        closedFolderIcon.setTranslateY(7);

        Label dirName = new Label();
        dirName.setMaxWidth(150);

        FontAwesomeIconView removeIcon = new FontAwesomeIconView(FontAwesomeIcon.REMOVE);

        Tooltip deleteToolTip = new Tooltip();
        deleteToolTip.setText("Verzeichnis aus Workspace entfernen");

        Button button = new Button(null, removeIcon);
        button.setTooltip(deleteToolTip);
        button.setTranslateX(8);

        return new TreeCell<String>() {
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                if (item == null || empty) {
                    setGraphic(null);
                    setText(null);
                } else if (getTreeItem() instanceof FilePathTreeItem) {
                    hbox.getChildren().clear();
                    dirName.setText(item);
                    if (getTreeItem().isExpanded()) {
                        hbox.getChildren().add(openFolderIcon);
                    } else {
                        hbox.getChildren().add(closedFolderIcon);
                    }
                    hbox.getChildren().add(dirName);
                    TreeItem<String> treeItem = getTreeItem();
                    TreeItem<String> parent = treeItem != null ? treeItem.getParent() : null;
                    if (parent != null && parent.equals(folderTree.getRoot())) {
                        String path = ((FilePathTreeItem) getTreeItem()).getFullPath();
                        button.setOnAction(event -> handleDeleteDirectory(Paths.get(path)));
                        hbox.getChildren().add(button);
                    }
                    setGraphic(hbox);
                }
            }
        };
    });
}

From source file:org.jacp.demo.perspectives.ContactPerspective.java

@PostConstruct
/**//from w w w.j av a2  s  .c o  m
 * create buttons in tool bars; menu entries
 */
public void PostConstructPerspective(final FXComponentLayout layout, final ResourceBundle resourceBundle) {
    LOGGER.debug("PostConstructPerspective ressource:" + resourceBundle);
    // create button in toolbar; button should switch top and bottom id's
    final JACPToolBar north = layout.getRegisteredToolBar(NORTH);
    final JACPToolBar south = layout.getRegisteredToolBar(SOUTH);
    final JACPToolBar west = layout.getRegisteredToolBar(WEST);
    final JACPToolBar east = layout.getRegisteredToolBar(EAST);

    final Button custom = new Button("switch");
    custom.setTooltip(new Tooltip("Switch Components"));
    custom.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent e) {
            context.send(SWITCH_MESSAGE);

        }
    });
    north.addOnEnd(context.getId(), custom);

    // TEST OPTIONBUTTON ON NORTH
    north.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    north.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    north.add(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    west.add(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    west.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    west.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    east.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    east.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    east.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    south.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));
    south.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));
    south.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));

    JACPHoverMenu menu = new JACPHoverMenu("Hovermenu", layout);

    VBox p = new VBox();
    p.setPadding(new Insets(10));
    Button b = new Button("HELLO");
    CheckBox check = new CheckBox("checkbox");

    p.getChildren().addAll(b, check);

    ColorPicker picker = new ColorPicker();
    menu.getContentPane().getChildren().add(p);

    north.addToCenter(context.getId(), menu);
    north.addToCenter(context.getId(), picker);

}

From source file:ubicrypt.ui.ctrl.providers.ProvidersController.java

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    String fxml = substringBefore(substringAfterLast(url.getFile(), "/"), ".fxml");
    navigator = new StackNavigator(root, fxml, controllerFactory);
    providers.setCellFactory(listView -> new ListCell<ProviderItem>() {
        @Override/*from  ww  w.  j  av  a2  s . co  m*/
        protected void updateItem(ProviderItem pi, boolean empty) {
            super.updateItem(pi, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
                return;
            }
            setContextMenu(pi.getContextMenu());
            Platform.runLater(() -> setGraphic(pi.getGraphics()));
        }
    });
    providerDescriptors.stream().forEach(pd -> {
        Button button = new Button();
        Image img = pd.getLogo().getImage();
        ImageView view = new ImageView(img);
        view.setFitWidth(30.0);
        view.setPickOnBounds(true);
        view.setPreserveRatio(true);
        button.setGraphic(view);
        button.setOnMouseClicked(mouseEvent -> {
            log.debug("adding provider :{}", pd.getCode());
            navigator.browse(format("provider/%s", pd.getCode()));
        });
        button.setTooltip(new Tooltip("Add " + pd.getDescription()));
        availableProviders.getItems().add(button);
    });

    //provider status events
    providerEvent.subscribe(pevent -> {
        UbiProvider provider = pevent.getHook().getProvider();
        if (!providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst()
                .isPresent()) {
            log.info("add new provider:{}", pevent.getHook().getProvider());
            String code = providerDescriptors.stream().filter(pd -> pd.getType() == provider.getClass())
                    .map(ProviderDescriptor::getCode).findFirst().get();
            final ProviderItem providerItem = new ProviderItem(provider, providerDescriptors.stream()
                    .filter(pd -> pd.getType() == provider.getClass()).findFirst().get(), providerRemover,
                    navigator);
            providers.getItems().add(providerItem);
            pevent.getHook().getStatusEvents().subscribe(providerItem::changeStatus);
        }
        switch (pevent.getEvent()) {
        case removed:
            //TODO: remove provider
            break;
        default:
            log.warn("unmanaged event:{}", pevent.getEvent());
        }
        providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst()
                .ifPresent(pi -> pi.changeStatus(pevent.getEvent()));
    });
}