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