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


Java ToggleButton.setSelected方法代码示例

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


在下文中一共展示了ToggleButton.setSelected方法的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: createToolbar

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
@FXThread
protected void createToolbar(@NotNull final HBox container) {
    super.createToolbar(container);

    lightButton = new ToggleButton();
    lightButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_LIGHTS));
    lightButton.setGraphic(new ImageView(Icons.LIGHT_16));
    lightButton.setSelected(true);
    lightButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeLight(newValue));

    audioButton = new ToggleButton();
    audioButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_AUDIO));
    audioButton.setGraphic(new ImageView(Icons.AUDIO_16));
    audioButton.setSelected(true);
    audioButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeAudio(newValue));

    DynamicIconSupport.addSupport(lightButton, audioButton);

    FXUtils.addClassesTo(lightButton, audioButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);

    FXUtils.addToPane(lightButton, container);
    FXUtils.addToPane(audioButton, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:25,代码来源:SceneFileEditor.java

示例3: createBottomNavigation

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private BottomNavigation createBottomNavigation(final Speaker activeSpeaker) {

        BottomNavigation bottomNavigation = new BottomNavigation();

        final ToggleButton infoButton = bottomNavigation.createButton(OTNBundle.getString("OTN.BUTTON.INFO"), MaterialDesignIcon.INFO.graphic(), e -> {
            // when clicked create a label in a scrollpane. Label will contain
            // the speaker summary
            Label speakerSummary = new Label(activeSpeaker.getSummary());
            speakerSummary.setWrapText(true);
            speakerSummary.getStyleClass().add("speaker-summary");
            speakerView.setCenter(createScrollPane(speakerSummary));
        });

        final ToggleButton sessionsButton = bottomNavigation.createButton(OTNBundle.getString("OTN.BUTTON.SESSIONS"), MaterialDesignIcon.EVENT_NOTE.graphic(), e -> {
            // when clicked we create a pane containing all sessions.
            speakerView.setCenter(createSessionsListView(activeSpeaker));
        });

        bottomNavigation.getActionItems().addAll(infoButton, sessionsButton);

        // listen to the selected toggle so we ensure it is selected when the view is returned to
        infoButton.getToggleGroup().selectedToggleProperty().addListener((o,ov,nv) -> lastSelectedButton = nv);
        infoButton.setSelected(true);

        return bottomNavigation;
    }
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:27,代码来源:SpeakerPresenter.java

示例4: handle

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void handle(final MouseEvent event) {
    final ToggleButton button = (ToggleButton) event.getSource();
    if (button.isSelected()) {
        final FileChooser fileChooser = new FileChooser();
        fileChooser.setInitialFileName("record.wav");
        fileChooser.setInitialDirectory(new File(System.getProperty("java.io.tmpdir")));
        fileChooser.setTitle("Save File");
        final File fileToWrite = fileChooser.showSaveDialog(CoreController.getStage());
        componentOut.getLineOut().setFileToWrite(fileToWrite);
        componentOut.getLineOut().startRecord();
        button.setSelected(true);
        button.setText("Stop");
        button.setTextFill(Color.RED);
    } else {
        componentOut.getLineOut().stopRecord();
        button.setSelected(false);
        button.setText("Record");
    }
    event.consume();
}
 
开发者ID:StephaneMangin,项目名称:Synth,代码行数:22,代码来源:Controller.java

示例5: prepareScene

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void prepareScene(final Stage stage) {
    testedStage = stage;

    PropertiesTable tb = new PropertiesTable(testedStage);
    PropertyTablesFactory.explorePropertiesList(testedStage, tb);

    final ToggleButton toggle = new ToggleButton("Fullscreen state : false");
    toggle.setSelected(false);
    toggle.selectedProperty().addListener(new ChangeListener<Boolean>(){

        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
            toggle.setText("Fullscreen state : " + t1);
            stage.setFullScreen(t1);
        }
    });

    VBox vb = (VBox) getRoot();
    vb.setPadding(new Insets(5, 5, 5, 5));
    vb.setStyle("-fx-border-color : green;");

    vb.getChildren().addAll(tb, toggle);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:23,代码来源:NewStageApp.java

示例6: createToggleButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createToggleButton(final ActionDescription action)
{
    final ToggleButton button = new ToggleButton();
    try
    {
        button.setGraphic(new ImageView(new Image(ResourceUtil.openPlatformResource(action.getIconResourcePath()))));
    }
    catch (final Exception ex)
    {
        logger.log(Level.WARNING, "Cannot load action icon", ex);
    }
    button.setTooltip(new Tooltip(action.getToolTip()));
    button.setSelected(true);
    button.selectedProperty()
          .addListener((observable, old_value, enabled) -> action.run(this, enabled) );
    return button;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:18,代码来源:DisplayEditor.java

示例7: bindToCuteElement

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void bindToCuteElement(CuteElement editableCopyOfCE, CuteElement origCE) {
	relationChecker = (RelationToNumberChecker) editableCopyOfCE;
	origRelationChecker = (RelationToNumberChecker) origCE;
	
	BooleanNumberOperator operator = relationChecker.getOperator();
	setOperatorHintBasedOnOperator(operator);
	
	ToggleButton t = mapWithButtons.get(operator.name());
	t.setSelected(true);
	ToggleGroup tg = segmentedButton.getToggleGroup();
	tg.selectedToggleProperty().addListener(toggleListener);
	
	numberTextField.numberProperty().bindBidirectional(relationChecker.compareNumberProperty());
	
	// Let's set descriptions for operator popovers.
	for (ToggleButton button: segmentedButton.getButtons()) {
		BooleanNumberOperator ButtonOperator = BooleanNumberOperator.valueOf(button.getText());
		String description = relationChecker.getFullDescriptionOfOperator(ButtonOperator);
		// Create popover (kind of tooltip) with description for each button.
		Label popOverLabel = new Label(description);
		popOverLabel.setPadding(new Insets(5,5,5,5));
		GUIUtil.setPopOverTooltipToNode(button, popOverLabel, -7);
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:26,代码来源:AbstractRelationToNumberCheckerController.java

示例8: start

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
    stage.setTitle("Toggle Button Sample");
    stage.setWidth(250);
    stage.setHeight(180);
    
    HBox hbox = new HBox();
    VBox vbox = new VBox();        
    
    Scene scene = new Scene(new Group(vbox));
    stage.setScene(scene);
    scene.getStylesheets().add("togglebuttonsample/ControlStyle.css");

    Rectangle rect = new Rectangle();
    rect.setHeight(50);
    rect.setFill(Color.WHITE);
    rect.setStroke(Color.DARKGRAY);
    rect.setStrokeWidth(2);
    rect.setArcHeight(10);
    rect.setArcWidth(10);

    final ToggleGroup group = new ToggleGroup();

    group.selectedToggleProperty().addListener(
        (ObservableValue<? extends Toggle> ov, 
        Toggle toggle, Toggle new_toggle) -> {
        if (new_toggle == null)
            rect.setFill(Color.WHITE);
        else
            rect.setFill((Color) group.getSelectedToggle().getUserData());
    });

    ToggleButton tb1 = new ToggleButton("Minor");
    tb1.setToggleGroup(group);
    tb1.setUserData(Color.LIGHTGREEN);
    tb1.setSelected(true);
    tb1.getStyleClass().add("toggle-button1");

    ToggleButton tb2 = new ToggleButton("Major");
    tb2.setToggleGroup(group);
    tb2.setUserData(Color.LIGHTBLUE);
    tb2.getStyleClass().add("toggle-button2");

    ToggleButton tb3 = new ToggleButton("Critical");
    tb3.setToggleGroup(group);
    tb3.setUserData(Color.SALMON);
    tb3.getStyleClass().add("toggle-button3");

    

    hbox.getChildren().addAll(tb1, tb2, tb3);

    vbox.getChildren().add(new Label("Priority:"));
    vbox.getChildren().add(hbox);
    vbox.getChildren().add(rect);
    vbox.setPadding(new Insets(20, 10, 10, 20));

          
    stage.show();
    rect.setWidth(hbox.getWidth());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:62,代码来源:ToggleButtonSample.java

示例9: YearPage

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Constructs a new year page.
 */
public YearPage() {
    getStyleClass().add("year-page"); //$NON-NLS-1$

    this.yearView = new YearView();

    this.monthSheetView = new MonthSheetView();
    this.monthSheetView.setCellFactory(param -> new MonthSheetView.DetailedDateCell(param.getView(), param.getDate()));
    this.monthSheetView.setClickBehaviour(ClickBehaviour.SHOW_DETAILS);

    bind(yearView, true);
    bind(monthSheetView, true);

    Bindings.bindBidirectional(monthSheetView.showTodayProperty(), showTodayProperty());

    setDateTimeFormatter(DateTimeFormatter.ofPattern(Messages.getString("YearPage.DATE_FORMAT"))); //$NON-NLS-1$

    displayModeProperty().addListener(it -> updateDisplayModeIcon());

    displayModeButton = new ToggleButton();
    displayModeButton.setId("display-mode-button");
    displayModeButton.setTooltip(new Tooltip(Messages.getString("YearPage.TOOLTIP_DISPLAY_MODE")));
    displayModeButton.setSelected(getDisplayMode().equals(DisplayMode.COLUMNS));
    displayModeButton.selectedProperty().addListener(it -> {
        if (displayModeButton.isSelected()) {
            setDisplayMode(DisplayMode.COLUMNS);
        } else {
            setDisplayMode(DisplayMode.GRID);
        }
    });

    displayModeProperty().addListener(it -> displayModeButton.setSelected(getDisplayMode().equals(DisplayMode.COLUMNS)));

    updateDisplayModeIcon();
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:38,代码来源:YearPage.java

示例10: switchMode

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Switch editing mode.
 */
private void switchMode(@NotNull final ActionEvent event) {

    final ToggleButton source = (ToggleButton) event.getSource();

    if (!source.isSelected()) {
        source.setSelected(true);
        return;
    }

    getToggleButtons().forEach(source, (button, arg) -> button !=
            arg, (toggleButton, arg) -> toggleButton.setSelected(false));

    final ObjectDictionary<ToggleButton, Pane> buttonToSettings = getButtonToSettings();
    final Pane settings = buttonToSettings.get(source);

    final VBox controlSettings = getControlSettings();
    final ObservableList<javafx.scene.Node> children = controlSettings.getChildren();
    children.clear();

    if (settings != null) {
        children.add(settings);
    }

    final ObjectDictionary<ToggleButton, TerrainToolControl> buttonToControl = getButtonToControl();
    final TerrainToolControl toolControl = buttonToControl.get(source);

    setToolControl(toolControl);

    if (!isShowed()) return;

    EXECUTOR_MANAGER.addJMETask(() -> {
        final Node cursorNode = getCursorNode();
        cursorNode.removeControl(TerrainToolControl.class);
        cursorNode.addControl(toolControl);
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:40,代码来源:TerrainEditingComponent.java

示例11: updateTransformTool

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
 * Switch transformation type.
 */
@FXThread
private void updateTransformTool(@NotNull final TransformType transformType, @NotNull final Boolean newValue) {

    final MA editor3DState = getEditor3DState();
    final ToggleButton scaleToolButton = getScaleToolButton();
    final ToggleButton moveToolButton = getMoveToolButton();
    final ToggleButton rotationToolButton = getRotationToolButton();

    if (newValue != Boolean.TRUE) {
        if (editor3DState.getTransformType() == transformType) {
            if (transformType == TransformType.MOVE_TOOL) {
                moveToolButton.setSelected(true);
            } else if (transformType == TransformType.ROTATE_TOOL) {
                rotationToolButton.setSelected(true);
            } else if (transformType == TransformType.SCALE_TOOL) {
                scaleToolButton.setSelected(true);
            }
        }
        return;
    }

    final ES editorState = getEditorState();
    editor3DState.setTransformType(transformType);

    if (transformType == TransformType.MOVE_TOOL) {
        rotationToolButton.setSelected(false);
        scaleToolButton.setSelected(false);
    } else if (transformType == TransformType.ROTATE_TOOL) {
        moveToolButton.setSelected(false);
        scaleToolButton.setSelected(false);
    } else if (transformType == TransformType.SCALE_TOOL) {
        rotationToolButton.setSelected(false);
        moveToolButton.setSelected(false);
    }

    if (editorState != null) {
        editorState.setTransformationType(transformType.ordinal());
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:43,代码来源:AbstractSceneFileEditor.java

示例12: CommonPropertiesScene

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
public CommonPropertiesScene(String controlName, int width, int height) {
    super(new HBox(), width, height);

    Utils.addBrowser(this);
    hb.setPadding(new Insets(5, 5, 5, 5));
    hb.setStyle("-fx-border-color : green;");

    setTestedControlContainerSize(defaultTestedControlPaneWidth, defaultTestedControlPaneHeight);
    testedControlContainer.setStyle("-fx-border-color : red;");

    ToggleButton visibility = new ToggleButton("V");
    visibility.setSelected(true);
    nonTestedContentVisibility.bindBidirectional(visibility.selectedProperty());
    visibility.setMinSize(10, 10);
    visibility.setPrefSize(10, 10);
    visibility.setMaxSize(10, 10);

    HBox headerHb = new HBox(5);
    headerHb.getChildren().addAll(visibility, new Label("Pane with tested " + controlName));

    leftVBox.getChildren().addAll(headerHb, testedControlContainer, controllersVb);

    leftVBox.setSpacing(5);
    //Main scene layout.
    prepareMainSceneStructure();

    nonTestedContentVisibility.addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
            controllersVb.setVisible(t1);
            propertiesPane.setVisible(t1);
        }
    });

    prepareScene();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:36,代码来源:CommonPropertiesScene.java

示例13: addNoneButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ButtonBase addNoneButton() {
	final LocatedImage none = new LocatedImage("/images/blank_page.png");

	final InputStream isThumbnail = ArenaBackgroundsSlide.class.getResourceAsStream("/images/blank_page.png");
	final ImageView thumbnailView = new ImageView(new Image(isThumbnail, 60, 60, true, true));

	final ToggleButton noneButton = (ToggleButton) itemPane.addButton(none, "None", Optional.of(thumbnailView),
			Optional.empty());
	noneButton.setSelected(true);
	itemPane.setDefault(none);

	return noneButton;
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:14,代码来源:ArenaBackgroundsSlide.java

示例14: addNoneButton

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton addNoneButton() {
	final ToggleButton noneButton = (ToggleButton) exerciseItemPane.addButton(noneExercise, "None");
	noneButton.setSelected(true);
	exerciseItemPane.setDefault(noneExercise);

	return noneButton;
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:8,代码来源:ExerciseSlide.java

示例15: setValue

import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void setValue(ValueType value) {
  if (value != null) {
    String stringValue = value.toString();
    ObservableList<ToggleButton> buttons = segmentedButton.getButtons();
    for (ToggleButton button : buttons) {
      if (button.getText().equals(stringValue)) {
        button.setSelected(true);
        break;
      }
    }
  }
}
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:14,代码来源:ToggleEditor.java


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