當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。