當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.setUserData方法代碼示例

本文整理匯總了Java中javafx.scene.control.Button.setUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setUserData方法的具體用法?Java Button.setUserData怎麽用?Java Button.setUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.Button的用法示例。


在下文中一共展示了Button.setUserData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import javafx.scene.control.Button; //導入方法依賴的package包/類
public Button build(String name, Association association) {

        EventBus eventBus = toolBox.getEventBus();

        Button button = new JFXButton(name);
        button.setUserData(association);
        button.getStyleClass().add("abpanel-button");
        button.setOnAction(event -> {
            ArrayList<Annotation> annotations = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
            eventBus.send(new CreateAssociationsCmd(association, annotations));
        });
        button.setTooltip(new Tooltip(association.toString()));

        ContextMenu contextMenu = new ContextMenu();
        MenuItem deleteButton = new MenuItem(toolBox.getI18nBundle().getString("cbpanel.conceptbutton.delete"));
        deleteButton.setOnAction(event ->
                ((Pane) button.getParent()).getChildren().remove(button));
        contextMenu.getItems().addAll(deleteButton);
        button.setContextMenu(contextMenu);

        return button;

    }
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:24,代碼來源:AssocButtonFactory.java

示例2: updateCells

import javafx.scene.control.Button; //導入方法依賴的package包/類
@Override
protected void updateCells() {
    final Calendar calendar = (Calendar) calendarView.getCalendar().clone();

    int year = calendar.get(Calendar.YEAR);
    // Get the beginning of the decade.
    int a = year % 10;
    if (a < 5) {
        a += 10;
    }
    int startYear = year - a;
    for (int i = 0; i < 10 * NUMBER_OF_DECADES; i++) {
        final int y = i + startYear;
        calendar.set(Calendar.YEAR, y);
        calendar.set(Calendar.MONTH, 0);
        calendar.set(Calendar.DATE, 1);
        Button button = (Button) getChildren().get(i);

        boolean disabled = normalizedMaxDate.get() != null && calendar.getTime().after(normalizedMaxDate.get());
        calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
        calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
        disabled = disabled || normalizedMinDate.get() != null && calendar.getTime().before(normalizedMinDate.get());

        button.setDisable(disabled);
        button.setText(Integer.toString(y));
        button.setUserData(y);
    }
    title.set(String.format("%s - %s", startYear, startYear + 10 * NUMBER_OF_DECADES - 1));
}
 
開發者ID:scourgemancer,項目名稱:graphing-loan-analyzer,代碼行數:30,代碼來源:CalendarViewSkin.java

示例3: createAndSetupButtons

import javafx.scene.control.Button; //導入方法依賴的package包/類
/**
 * Will create an {@link HBox} for every {@link SAMPVersion}, said {@link HBox}
 * will contain a {@link Label} and a {@link Button}.
 */
private void createAndSetupButtons() {
	for (final InstallationCandidate candidate : INSTALLATION_CANDIDATES) {
		final HBox versionContainer = new HBox();

		if (!buttonContainer.getChildren().isEmpty()) {
			buttonContainer.getChildren().add(new Separator());
		}

		versionContainer.getStyleClass().add("installEntry");

		final Label title = new Label(MessageFormat.format(SAMP_VERSION, candidate.getName()));
		title.getStyleClass().add("installLabel");
		title.setMaxWidth(Double.MAX_VALUE);

		final Button installButton = new Button(INSTALL_TEXT);
		installButton.setUserData(candidate);
		installButton.setOnAction(__ -> installAction(installButton));
		installButton.getStyleClass().add("installButton");
		buttons.add(installButton);

		versionContainer.getChildren().add(title);
		versionContainer.getChildren().add(installButton);

		buttonContainer.getChildren().add(versionContainer);

		HBox.setHgrow(title, Priority.ALWAYS);
	}
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:33,代碼來源:VersionChangeController.java

示例4: build

import javafx.scene.control.Button; //導入方法依賴的package包/類
public Button build(String name) {

        Button button = new JFXButton(name);
        button.setUserData(USERDATA);
        button.getStyleClass().add("cbpanel-button");
        button.setOnAction(event ->
            eventBus.send(new CreateAnnotationFromConceptCmd(button.getText())));

        // Add contextMenu
        ContextMenu contextMenu = new ContextMenu();
        MenuItem showInTreeItem = new MenuItem(i18n.getString("cbpanel.conceptbutton.findconcept"));
        showInTreeItem.setOnAction(event -> {
                ShowConceptInTreeViewMsg msg = new ShowConceptInTreeViewMsg(button.getText());
                eventBus.send(msg);
        });
        MenuItem deleteButton = new MenuItem(i18n.getString("cbpanel.conceptbutton.delete"));
        deleteButton.setOnAction(event ->
            ((Pane) button.getParent()).getChildren().remove(button));
        contextMenu.getItems().addAll(showInTreeItem, deleteButton);
        button.setContextMenu(contextMenu);

        button.setOnDragDetected(evt -> {
            if (button.getText() != null) {
                // Drag the string name to some target.
                Dragboard db = button.startDragAndDrop(TransferMode.MOVE);
                ClipboardContent content = new ClipboardContent();
                content.putString(name);
                db.setContent(content);
                evt.consume();
            }
        });

        conceptService.findDetails(name)
                .thenApply(opt -> {
                    if (!opt.isPresent()) {
                        Platform.runLater(() -> {
                            button.getStyleClass().add("button-invalid");
                            button.setOnAction(e -> {});
                        });
                    }
                    return null;
                });

        return button;
    }
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:46,代碼來源:ConceptButtonFactory.java


注:本文中的javafx.scene.control.Button.setUserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。