当前位置: 首页>>代码示例>>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;未经允许,请勿转载。