当前位置: 首页>>代码示例>>Java>>正文


Java ToggleButton.setOnAction方法代码示例

本文整理汇总了Java中javafx.scene.control.ToggleButton.setOnAction方法的典型用法代码示例。如果您正苦于以下问题:Java ToggleButton.setOnAction方法的具体用法?Java ToggleButton.setOnAction怎么用?Java ToggleButton.setOnAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ToggleButton的用法示例。


在下文中一共展示了ToggleButton.setOnAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WeekPage

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Constructs a new week page.
 */
public WeekPage() {
    getStyleClass().add("week-page"); //$NON-NLS-1$
    setDateTimeFormatter(DateTimeFormatter.ofPattern(Messages.getString("WeekPage.DATE_FORMAT"))); //$NON-NLS-1$

    this.detailedWeekView = new DetailedWeekView();

    ToggleButton layoutButton = new ToggleButton();
    layoutButton.setTooltip(new Tooltip(Messages.getString("WeekPage.TOOLTIP_LAYOUT"))); //$NON-NLS-1$
    layoutButton.setId("layout-button");
    Text layoutIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.TABLE);
    layoutIcon.getStyleClass().addAll("button-icon", "layout-button-icon"); //$NON-NLS-1$ //$NON-NLS-2$
    layoutButton.setGraphic(layoutIcon);
    layoutButton.setSelected(getLayout().equals(Layout.SWIMLANE));
    layoutButton.setOnAction(evt -> {
        if (layoutButton.isSelected()) {
            setLayout(Layout.SWIMLANE);
        } else {
            setLayout(Layout.STANDARD);
        }
    });

    showLayoutButtonProperty().addListener(it -> updateToolBarControls(layoutButton));

    updateToolBarControls(layoutButton);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:29,代码来源:WeekPage.java

示例2: setupButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton setupButton(ToggleGroup group, ComponentLauncherInfo componentInfo) {
	ToggleButton button = new ToggleButton(componentInfo.name.getValue(), setupImageView(componentInfo.image));
	button.setAlignment(Pos.CENTER_LEFT);
	button.setToggleGroup(group);
	button.setMinHeight(30);
	button.setMaxWidth(Double.MAX_VALUE);
	button.setOnAction(e -> {
		if(button.isSelected()) {
			modifiedSelection(componentInfo);
		} else {
			modifiedSelection(null);
		}
	});
	GridPane.setHgrow(button, Priority.ALWAYS);
	return button;
}
 
开发者ID:ra4king,项目名称:CircuitSim,代码行数:17,代码来源:CircuitSim.java

示例3: createMaximizeButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createMaximizeButton() {
    ToggleButton button = new ToggleButton();

    button.setId("maximizeButton");
    button.setOnAction((e) -> {
        JFrame frame = (JFrame) parent;

        if (frame.isResizable()) {
            if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == 0) {
                frame.getRootPane().setBorder(BorderFactory.createEmptyBorder());
                frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
            } else {
                frame.getRootPane().setBorder(BorderFactory.createMatteBorder(
                        0, 3, 3, 3,
                        Color.decode("#222222")));
                frame.setExtendedState(JFrame.NORMAL);
            }
        }
    });

    return button;
}
 
开发者ID:Wingman,项目名称:wingman,代码行数:23,代码来源:FrameTitleBar.java

示例4: addTexture

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void addTexture(final TerrainTexture tex, final boolean isGlobal) {
	final Canvas preview = new Canvas(64, 32);
	final GraphicsContext gc = preview.getGraphicsContext2D();
	gc.setFill(tex.samplePaint);
	gc.fillRect(0, 0, 64, 32);

	final ToggleButton t = new ToggleButton("", preview);
	t.setFocusTraversable(false);
	t.setToggleGroup(toolsGroup);
	t.setContextMenu(new ToolContextMenu(this, AssetType.TEXTURE, tex.id, isGlobal));

	t.setOnAction(event -> {
		if (t.isSelected()) canvas.setTool(new TerrainTextureTool(tex));
		else canvas.setTool(null);
	});

	if (isGlobal) {
		textures.global.getChildren().add(t);
		textureButtonsG.put(tex.id, t);
	} else {
		textures.local.getChildren().add(t);
		textureButtonsL.put(tex.id, t);
	}
}
 
开发者ID:CLowcay,项目名称:iso-game-engine,代码行数:25,代码来源:LibraryPane.java

示例5: makeSpriteButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton makeSpriteButton(
	final SpriteInfo sprite,
	final Canvas preview,
	final FacingDirection direction,
	final ToolContextMenu menu
) {
	final ToggleButton t = new ToggleButton("", preview);
	t.setFocusTraversable(false);
	t.setToggleGroup(toolsGroup);

	t.setOnAction(event -> {
		if (t.isSelected()) canvas.setTool(new SpriteTool(sprite, direction));
		else canvas.setTool(null);
	});

	if (menu != null) t.setContextMenu(menu);

	return t;
}
 
开发者ID:CLowcay,项目名称:iso-game-engine,代码行数:20,代码来源:LibraryPane.java

示例6: start

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
	this.stage = stage;
	configureScene();
	configureStage();
	ToggleGroup tg = new ToggleGroup();
	final ToggleButton tb1 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(true)).text("Not present in family").build();
	tb1.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent arg0) {
			if(tb1.selectedProperty().get()){
				System.out.println("Selected");
			}else{
				System.out.println("Deselected");
			}
		}
	});
	ToggleButton tb2 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(false)).text("Not present in family").build();
	
	// Logic starts
	HBox hb = HBoxBuilder.create().spacing(15).build();
	hb.getChildren().addAll(tb1,tb2);
	root.getChildren().add(hb);
	//ScenicView.show(scene);
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:26,代码来源:ToggleButtonGraphicStylingDemo.java

示例7: setUpButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void setUpButton(ToggleButton button, RelayData.State relayState) {
  button.setOnAction(event -> {
    if (button.isSelected()) {
      setData(dataOrDefault.get().withState(relayState));
    } else {
      setDefaultState();
    }
  });
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:10,代码来源:RelayWidget.java

示例8: createFlyout

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Creates and returns a {@link Flyout}
 * @return  a new {@link Flyout}
 */
public Flyout createFlyout() {
    stuffChooserTrigger = new ToggleButton("Create / Select Item");
    stuffChooserTrigger.setOnAction(e -> {
        if(stuffChooserTrigger.isSelected()) {
            flyout.flyout();
        }else{
            flyout.dismiss();
        }
    });
    
    Flyout retVal = new Flyout(stuffChooserTrigger, getStuffControl(), null);
    
    return retVal;
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:19,代码来源:FlyoutDemo.java

示例9: createFlyout

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Creates and returns a {@link Flyout}
 * @return  a new {@link Flyout}
 */
public Flyout createFlyout() {
    stuffChooserTrigger = new ToggleButton("Create / Select Item");
    stuffChooserTrigger.setOnAction(e -> {
        if(stuffChooserTrigger.isSelected()) {
            flyout.flyout();
        }else{
            flyout.dismiss();
        }
    });
    
    Flyout retVal = new Flyout(stuffChooserTrigger, getStuffControl());
    
    return retVal;
}
 
开发者ID:fxpresso,项目名称:tidbit,代码行数:19,代码来源:FlyoutDemo.java

示例10: ColorChooser

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
public ColorChooser( String initialColor,
                     String tooltipText ) {
    this.colorPicker = new ColorPicker();
    colorPicker.setTooltip( new Tooltip( tooltipText ) );
    box = new HBox( 2 );

    try {
        colorPicker.setValue( Color.valueOf( initialColor ) );
    } catch ( IllegalArgumentException e ) {
        log.warn( "Unable to set color picker's initial color to invalid color: {}", initialColor );
    }

    manualEditor = new ManualEditor( colorPicker.getValue(), tooltipText, colorPicker::setValue );
    addListener( ( observable -> {
        // only update the text if the currently visible control is the color picker
        if ( box.getChildren().get( 0 ) == colorPicker ) {
            manualEditor.colorField.setText( colorPicker.getValue().toString() );
        }
    } ) );

    ToggleButton editButton = AwesomeIcons.createToggleButton( AwesomeIcons.PENCIL, 10 );

    box.getChildren().addAll( colorPicker, editButton );

    editButton.setOnAction( event -> {
        ObservableList<Node> children = box.getChildren();
        if ( children.get( 0 ) == manualEditor ) {
            box.getChildren().set( 0, colorPicker );
        } else {
            box.getChildren().set( 0, manualEditor );
            manualEditor.colorField.requestFocus();
            manualEditor.colorField.selectAll();
        }
    } );
}
 
开发者ID:renatoathaydes,项目名称:LogFX,代码行数:36,代码来源:ColorChooser.java

示例11: createCategoryToggleButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * This method creates a new toggle button for a given engine category.
 *
 * @param category The engine category, for which a new toggle button should be created
 * @return The created toggle button
 */
private ToggleButton createCategoryToggleButton(EngineCategoryDTO category) {
    ToggleButton categoryButton = new SidebarToggleButton(category.getName());

    categoryButton.setId(String.format("%sButton", category.getName().toLowerCase()));
    categoryButton.setOnAction(event -> onCategorySelection.accept(category));

    return categoryButton;
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:15,代码来源:EnginesSidebar.java

示例12: createSettingsToggleButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * This method creates a toggle button for a given settings panel.
 *
 * @param item The settings panel together with its displayed name and icon css class
 * @return The created toggle button
 */
private ToggleButton createSettingsToggleButton(SettingsSidebarItem item) {
    ToggleButton toggleButton = new SidebarToggleButton(item.getName());

    toggleButton.getStyleClass().add(item.getIconClass());
    toggleButton.setOnAction(event -> onSelectSettingsItem.accept(item.getPanel()));

    return toggleButton;
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:15,代码来源:SettingsSidebar.java

示例13: createToggleButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createToggleButton(ToggleGroup grp, String styleClass, Runnable action, String toolTip) {
    ToggleButton button = new ToggleButton();
    button.setToggleGroup(grp);
    button.getStyleClass().add(styleClass);
    button.setOnAction(evt -> {
        action.run();
        area.requestFocus();
    });
    button.setPrefWidth(25);
    button.setPrefHeight(25);
    if (toolTip != null) {
        button.setTooltip(new Tooltip(toolTip));
    }
    return button;
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:16,代码来源:RichText.java

示例14: getToggleButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
public ToggleButton getToggleButton() {
    ToggleButton toggleButton = FXUIUtils.createToggleButton(name, description);
    toggleButton.setOnAction(this);
    return toggleButton;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:AbstractSimpleAction.java

示例15: createToolBarControls

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private Node createToolBarControls() {
    ToggleButton agendaOnlyButton = new ToggleButton();
    ToggleButton dayOnlyButton = new ToggleButton();
    ToggleButton standardButton = new ToggleButton();

    Text listIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.LIST);
    listIcon.getStyleClass().addAll("button-icon");
    agendaOnlyButton.setGraphic(listIcon);
    agendaOnlyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);

    Text calendarIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.CALENDAR);
    calendarIcon.getStyleClass().addAll("button-icon");
    dayOnlyButton.setGraphic(calendarIcon);
    dayOnlyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);

    Text standardIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.COLUMNS);
    standardIcon.getStyleClass().addAll("button-icon");
    standardButton.setGraphic(standardIcon);
    standardButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);

    agendaOnlyButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.AGENDA_ONLY));
    dayOnlyButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.DAY_ONLY));
    standardButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.STANDARD));

    SegmentedButton segmentedButton = new SegmentedButton(agendaOnlyButton, standardButton, dayOnlyButton);
    segmentedButton.getStyleClass().add("layout-button"); //$NON-NLS-1$
    segmentedButton.visibleProperty().bind(showDayPageLayoutControlsProperty());

    switch (getDayPageLayout()) {
        case AGENDA_ONLY:
            agendaOnlyButton.setSelected(true);
            break;
        case DAY_ONLY:
            dayOnlyButton.setSelected(true);
            break;
        case STANDARD:
            standardButton.setSelected(true);
            break;
        default:
            break;
    }

    agendaOnlyButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_MAXIMIZE_AGENDA_LIST"))); //$NON-NLS-1$
    dayOnlyButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_MAXIMIZE_DAY_VIEW"))); //$NON-NLS-1$
    standardButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_STANDARD_LAYOUT"))); //$NON-NLS-1$

    ToggleButton layoutButton = new ToggleButton();
    layoutButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_LAYOUT"))); //$NON-NLS-1$
    layoutButton.setId("layout-button");
    Text layoutIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.TABLE);
    layoutIcon.getStyleClass().addAll("button-icon", "layout-button-icon"); //$NON-NLS-1$ //$NON-NLS-2$
    layoutButton.setGraphic(layoutIcon);
    layoutButton.setSelected(getLayout().equals(Layout.SWIMLANE));
    layoutButton.setOnAction(evt -> {
        if (layoutButton.isSelected()) {
            setLayout(Layout.SWIMLANE);
        } else {
            setLayout(Layout.STANDARD);
        }
    });

    toolbarControls = new HBox();
    toolbarControls.setSpacing(10);

    updateToolBarControls(segmentedButton, layoutButton);

    showLayoutButtonProperty().addListener(it -> updateToolBarControls(segmentedButton, layoutButton));

    return toolbarControls;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:71,代码来源:DayPage.java


注:本文中的javafx.scene.control.ToggleButton.setOnAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。