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


Java ToggleButton类代码示例

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


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

示例1: start

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Override
    public void start(Stage stage) throws Exception {
        VBox root = new VBox();
        Label counterLabel = new Label("");
        ToggleButton startStopButton = new ToggleButton();
// Multicast the ToggleButton's true/false selected state
        Observable<Boolean> selectedStates =
                JavaFxObservable.valuesOf(startStopButton.selectedProperty())
                        .publish()
                        .autoConnect(2);
// Using switchMap() with ToggleButton's selected state willdrive
// whether to kick off an Observable.interval(),
// or dispose() it by switching to empty Observable
        selectedStates.switchMap(selected -> {
            if (selected)
                return Observable.interval(1,
                        TimeUnit.MILLISECONDS);
            else
                return Observable.empty();
        }).observeOn(JavaFxScheduler.platform()) // Observe on JavaFX UI thread
                .map(Object::toString)
                .subscribe(counterLabel::setText);
// Change ToggleButton's text depending on its state
        selectedStates.subscribe(selected ->
                startStopButton.setText(selected ? "STOP" :
                        "START")
        );
        root.getChildren().addAll(counterLabel, startStopButton);
        stage.setScene(new Scene(root));
        stage.show();
    }
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:32,代码来源:Ch7_16.java

示例2: 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

示例3: loadModes

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
private void loadModes(){
	modesBox.getChildren().clear();
	
	int count = Dashboard.getModeSelectorControl().getModesCount();
	modesButtons = new ToggleButton[count];
	
	for (int i = 0; i < modesButtons.length; i++) {
		modesButtons[i] = new ToggleButton(
				Dashboard.getModeSelectorControl().getMode(i).name);
		modesButtons[i].setMinSize(130, 20);
		modesButtons[i].setToggleGroup(modesToggleGroup);
		modesBox.getChildren().add(modesButtons[i]);
	}
	
	if(count > 0)
		modesButtons[0].setSelected(true);
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:18,代码来源:ModeSelectorWindow.java

示例4: 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

示例5: initItems

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
/**
 * 初始化选择项
 */
private void initItems(){
    // 左边的选择项
    ObservableList<Node> items = boxItems.getChildren();
    ToggleGroup group = new ToggleGroup();
    // 关联group和index
    for(int index=0; index<items.size(); ++index){
        ToggleButton item = (ToggleButton) items.get(index);
        item.setToggleGroup(group);
        item.setUserData(index);
    }
    // 切换监听
    group.selectedToggleProperty().addListener((observable, oldValue, newValue) ->{
        if(newValue != null){
            Integer itemIndex = (Integer) newValue.getUserData();
            showSettingContent(itemIndex);
        }else{
            group.selectToggle(oldValue);
        }
    });
    // 默认选择第一个
    group.getToggles().get(0).setSelected(true);
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:26,代码来源:SettingsActivity.java

示例6: 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

示例7: 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

示例8: getConstructorPage

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    ToggleButton default_button = new ToggleButton(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new ToggleButton(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }

    Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100));
    ToggleButton graphic_button = new ToggleButton(GRAPHICS_BUTTON, rectangle);
    defaultLayout.apply(graphic_button);
    if (!graphic_button.getText().equals(GRAPHICS_BUTTON) || graphic_button.getGraphic() != rectangle) {
        reportGetterFailure("new ToggleButton(GRAPHICS_LABEL, rectangle)");
    } else {
        list.add(graphic_button);
    }

    return list;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:24,代码来源:ToggleButtonsApp.java

示例9: setup

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Override
protected TestNode setup() {
    TestNode root = new TestNode();
    defFill(root);
    ArrayList<Change<Labeled>> list = new ArrayList<Change<Labeled>>();
    list.add(new Change<Labeled>(Pages.setSelected.name()) {
        public void apply(Labeled labeled) {
            ToggleButton button = (ToggleButton) labeled;
            button.setSelected(true);
            if (button.isSelected() != true) {
                reportGetterFailure(getMarker());
            }
        }
    });
    root.add(new Page(list), Pages.setSelected.name());
    return root;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:ToggleButtonsApp.java

示例10: 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

示例11: informationAlertBasicWithButtonsTest

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Test(timeout = 300000)
public void informationAlertBasicWithButtonsTest() throws Throwable {
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (ButtonType b : types) {
            addButton(b.getText());
            Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_INFO_TEXT)).wrap();
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            checkScreenshot("informationAlertBasicWithButtonsTest" + s + "_" + b + "Test", scene);
            closeDialogWindowByClickingButton();
            Thread.sleep(DEFAULT_DELAY);
            throwScreenshotError();
        }
        deselectButtons();
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:DialogTest.java

示例12: confirmationAlertBasicWithButtonsTest

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Test(timeout = 300000)
public void confirmationAlertBasicWithButtonsTest() throws Throwable {
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (ButtonType b : types) {
            addButton(b.getText());
            Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_CONFIRM_TEXT)).wrap();
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            checkScreenshot("confirmationAlertBasicWithButtonsTest" + s + "_" + b + "Test", scene);
            closeDialogWindowByClickingButton();
            Thread.sleep(DEFAULT_DELAY);
            throwScreenshotError();
        }
        deselectButtons();
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:DialogTest.java

示例13: warningAlertBasicWithButtonsTest

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Test(timeout = 300000)
public void warningAlertBasicWithButtonsTest() throws Throwable {
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (ButtonType b : types) {
            addButton(b.getText());
            Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_WARNING_TEXT)).wrap();
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            checkScreenshot("warningAlertBasicWithButtonsTest" + s + "_" + b + "Test", scene);
            closeDialogWindowByClickingButton();
            Thread.sleep(DEFAULT_DELAY);
            throwScreenshotError();
        }
        deselectButtons();
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:DialogTest.java

示例14: errorAlertBasicWithButtonsTest

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Test(timeout = 300000)
public void errorAlertBasicWithButtonsTest() throws Throwable {
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (ButtonType b : types) {
            addButton(b.getText());
            Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_ERROR_TEXT, StringComparePolicy.EXACT)).wrap();
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            checkScreenshot("errorAlertBasicWithButtonsTest" + s + "_" + b + "Test", scene);
            closeDialogWindowByClickingButton();
            Thread.sleep(DEFAULT_DELAY);
            throwScreenshotError();
        }
        deselectButtons();
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:DialogTest.java

示例15: informationAlertResponceTest

import javafx.scene.control.ToggleButton; //导入依赖的package包/类
@Test(timeout = 300000)
public void informationAlertResponceTest() throws Throwable {
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (ButtonType b : types) {
            addButton(b.getText());
            Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_INFO_TEXT)).wrap();
            click(button, InputType.MOUSE);
            closeDialogWindowByClickingButton(b.getText());
            Wrap<? extends Node> resultField = parent.lookup(TextField.class, new ByID<TextField>(RESULT_FIELD_ID)).wrap();
            resultField.waitProperty(Wrap.TEXT_PROP_NAME, b.getText());
            Thread.sleep(DEFAULT_DELAY);
        }
        deselectButtons();
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:DialogTest.java


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