Java 类javafx.scene.control.ToggleButton 实例源码

项目:Learning-RxJava    文件:Ch7_16.java   
@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();
    }
项目:CalendarFX    文件:WeekPage.java   
/**
 * 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);
}
项目:FlashLib    文件:ModeSelectorWindow.java   
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);
}
项目:jmonkeybuilder    文件:SceneFileEditor.java   
@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);
}
项目:ApkToolPlus    文件:SettingsActivity.java   
/**
 * 初始化选择项
 */
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);
}
项目:javaone2016    文件:SpeakerPresenter.java   
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;
    }
项目:Synth    文件:Controller.java   
@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();
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@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;
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@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;
}
项目:openjfx-8u-dev-tests    文件:NewStageApp.java   
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);
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@Test(timeout = 300000)
public void warningAlertResponceTest() 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);
            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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@Test(timeout = 300000)
public void errorAlertResponceTest() 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)).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();
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@Test(timeout = 300000)
public void alertWithExpandableContentTest() throws Throwable {
    Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_EXP_TEXT)).wrap();
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (String c : content) {
            Wrap<? extends Node> contentToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(c)).wrap();
            click(contentToggleButton, InputType.MOUSE);
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            SceneDock sd = new SceneDock();
            click(sd.asParent().lookup(Hyperlink.class, new ByText<Hyperlink>("Show Details")).wrap(), InputType.MOUSE);
            // checkScreenshot("alertWithExpandableContentTest" + s + "_" + c + "Test", scene);
            Thread.sleep(DEFAULT_DELAY);
            closeDialogWindowByClickingButton("OK");
            throwScreenshotError();
        }
    }
}
项目:openjfx-8u-dev-tests    文件:DialogTest.java   
@Test(timeout = 300000)
public void alertWithCustomContentTest() throws Throwable {
    Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_CUSTOM_TEXT)).wrap();
    for (StageStyle s : StageStyle.values()) {
        Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
        click(styleToggleButton, InputType.MOUSE);
        for (String c : content) {
            Wrap<? extends Node> contentToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(c)).wrap();
            click(contentToggleButton, InputType.MOUSE);
            click(button, InputType.MOUSE);
            Thread.sleep(DEFAULT_DELAY);
            SceneDock sd = new SceneDock();
            checkScreenshot("alertWithCustomContentTest" + s + "_" + c + "Test", scene);
            Thread.sleep(DEFAULT_DELAY);
            closeDialogWindowByClickingButton("OK");
            throwScreenshotError();
        }
    }
}
项目:fxldemo-gradle    文件:FxlDemo.java   
public void start(Stage stage) throws Exception {
    stage.setTitle("Hello World");
    stage.initStyle(StageStyle.UNDECORATED);

    Label label = new Label(stage.getTitle());
    label.setStyle("-fx-font-size: 25");

    // Alibi for including ControlsFX Dependency :)
    SegmentedButton fxcontrol = new SegmentedButton(new ToggleButton("One"), new ToggleButton("Two"), new ToggleButton("Three"));

    Button exitButton = new Button("Exit");
    exitButton.setStyle("-fx-font-weight: bold");
    exitButton.setOnAction(event -> Platform.exit());

    VBox root = new VBox(label, fxcontrol, exitButton);
    root.setAlignment(Pos.CENTER);
    root.setSpacing(20);
    root.setPadding(new Insets(25));
    root.setStyle("-fx-border-color: lightblue");

    stage.setScene(new Scene(root));
    stage.show();
}
项目:CircuitSim    文件:CircuitSim.java   
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;
}
项目:JttDesktop    文件:AssignmentDetailArea.java   
/**
 * Constructs a new {@link AssignmentDetailArea}.
 * @param styling the associated {@link ManagementConsoleStyle}.
 * @param images the {@link ManagementConsoleImages}.
 */
AssignmentDetailArea( ManagementConsoleStyle styling, ManagementConsoleImages images ) {
   this.styling = styling;
   this.images = images;

   this.detailArea = new TextArea( NOT_SELECTED );
   setCenter( detailArea );

   this.lockButton = new ToggleButton();
   this.lockButton.setTooltip( new Tooltip( LOCK_TOOL_TIP ) );

   this.toolBox = new HBox();
   this.toolBox.setPadding( new Insets( 2 ) );
   this.toolBox.setAlignment( Pos.CENTER_RIGHT );
   this.toolBox.getChildren().add( lockButton );
   setTop( toolBox );
   this.styling.styleButtonSize( lockButton, images.constuctLockImage() );

   detailListener = this::detailChanged;

   lockButton.selectedProperty().addListener( this::handleLocking );
   lockButton.setSelected( true );
   lockButton.setDisable( true );
}
项目:wingman    文件:FrameTitleBar.java   
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;
}
项目:livro-javafx-pratico    文件:AprendendoTransicoes.java   
private HBox criaPainelSuperior() {
    HBox hbTopo = new HBox(10);
    hbTopo.setSpacing(10);
    hbTopo.setAlignment(Pos.CENTER);
    Transicoes[] transicoes = Transicoes.values();
    // grupo para todas as transições
    botoesTransicao = new ToggleGroup();
    Stream.of(transicoes).map(t -> {
        ToggleButton tb = new ToggleButton(t.name());
        tb.setUserData(t);
        tb.setToggleGroup(botoesTransicao);
        return tb;
    }).forEach(hbTopo.getChildren()::add);
    botoesTransicao.getToggles().get(0).setSelected(true);
    return hbTopo;
}
项目:qupath    文件:QuPathGUI.java   
public ToggleButton getActionToggleButton(GUIActions actionType, boolean hideActionText, ToggleGroup group) {
        Action action = getAction(actionType);
        ToggleButton button = ActionUtils.createToggleButton(action, hideActionText ? ActionTextBehavior.HIDE : ActionTextBehavior.SHOW);
        if (hideActionText && action.getText() != null) {
            Tooltip.install(button, new Tooltip(action.getText()));
//          button.setTooltip(new Tooltip(action.getText()));
////            button.setText(null);
        }

        // Internally, ControlsFX duplicates graphics (or gives up) because Nodes can't appear multiple times the scene graph
        // Consequently, we need to bind changes to the text fill here so that they filter through
        if (button.getGraphic() instanceof Glyph) {
            ((Glyph)button.getGraphic()).textFillProperty().bind(((Glyph)action.getGraphic()).textFillProperty());
        }

        if (group != null)
            button.setToggleGroup(group);
        return button;
    }
项目:LuoYing    文件:FpsAppState.java   
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    setEnabled(false);
    Jfx.runOnJfx(() -> {
        statisticsIcon = new ToggleButton();
        statisticsIcon.setTooltip(new Tooltip(Manager.getRes(ResConstants.COMMON_STATISTICS)));
        statisticsIcon.prefWidth(20);
        statisticsIcon.prefHeight(20);
        statisticsIcon.setPadding(Insets.EMPTY);
        statisticsIcon.setGraphic(JfxUtils.createIcon(AssetConstants.INTERFACE_ICON_STATISTICS));
        statisticsIcon.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
            Jfx.runOnJme(() -> {
                setEnabled(newValue);
            });
        });
        UIManager.ZONE_STATUS.getChildren().addAll(statisticsIcon);
    });
}
项目:LuoYing    文件:EditorStatsAppState.java   
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    stat = app.getRenderer().getStatistics();
    Jfx.runOnJfx(() -> {
        label.setVisible(false);
        statisticsIcon = new ToggleButton();
        statisticsIcon.setTooltip(new Tooltip(Manager.getRes(ResConstants.COMMON_STATISTICS)));
        statisticsIcon.prefWidth(20);
        statisticsIcon.prefHeight(20);
        statisticsIcon.setPadding(Insets.EMPTY);
        statisticsIcon.setGraphic(JfxUtils.createIcon(AssetConstants.INTERFACE_ICON_STATISTICS));
        statisticsIcon.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
            label.setVisible(newValue);
            setEnabled(newValue);
        });
        UIManager.ZONE_STATUS.getChildren().addAll(statisticsIcon, label);
    });
    labels = stat.getLabels();
    datas = new int[labels.length];
    stat.setEnabled(isEnabled());
}
项目:iso-game-engine    文件:LibraryPane.java   
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);
    }
}
项目:iso-game-engine    文件:LibraryPane.java   
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;
}
项目:iso-game-engine    文件:LibraryPane.java   
private ToggleButton makeCliffButton(
    final CliffTexture tex, final Canvas canvas,
    final SlopeType slope, final int elevation, final ToolContextMenu menu
) {
    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.translate(0, (1 - elevation) * 16);
    gc.scale(1.0d/4.0d, 1.0d/4.0d);
    try {
        (new Tile(elevation, slope, global.getTerrain("blank"), tex))
            .render(gc, CameraAngle.UL);
    } catch (CorruptDataException e) {
        throw new RuntimeException("Missing blank texture");
    }

    final ToggleButton t = new ToggleButton("", canvas);
    t.setFocusTraversable(false);
    t.setToggleGroup(toolsGroup);
    if (menu != null) t.setContextMenu(menu);

    return t;
}
项目:blackmarket    文件:ToggleButtonToolBar.java   
public ToggleButtonToolBar(boolean isVeritcal, List<T> list) {

    buttons = list.stream()
            .map(l -> {
                ToggleButton tb = 
                        l.icon().isPresent() ?
                                new ToggleButton(l.displayName(), new SmallIcon(l)) :
                                    new ToggleButton(l.displayName());
                tb.setUserData(l);
                return tb;
            })
            .collect(Collectors.toList());

    for (ButtonBase node : buttons) {
        node.setMaxWidth(Double.MAX_VALUE);
    }

       this.getChildren().addAll(buttons);
}
项目:blackmarket    文件:ItemTypePanes.java   
public ItemTypePanes(Consumer<List<ItemType>> onChangeConsumer) {
    this.onChangeConsumer = onChangeConsumer;
    itemTypesChkbxs = Arrays.asList(ItemType.values())
            .stream()
            .map(it -> {
                ToggleButton chbBx = new ToggleButton(it.displayName());
                chbBx.setUserData(it);
                chbBx.setMinWidth(PREF_TILE_WIDTH);
                chbBx.setMinHeight(PREF_TILE_HEIGHT);
                chbBx.setGraphic(new ImageView(ImageCache.getInstance().get(it.icon())));
                chbBx.setContentDisplay(ContentDisplay.RIGHT);
                chbBx.setOnAction(e -> checked());
                return chbBx;
            })
            .collect(Collectors.toList());

    itemTypePane1 = new ItemTypePane(itemTypesChkbxs.subList(0, 8));
    itemTypePane2 = new ItemTypePane(itemTypesChkbxs.subList(8, 17));
    itemTypePane3 = new ItemTypePane(itemTypesChkbxs.subList(17, 30));
}
项目:FXImgurUploader    文件:Demo.java   
@Override public void start(Stage stage) {
    PushButton control = PushButtonBuilder.create()
                                          .prefWidth(81)
                                          .prefHeight(43)
                                          .build();

    ToggleButton button = new ToggleButton("Push");
    button.setPrefSize(81, 43);
    button.getStylesheets().add(getClass().getResource("demo.css").toExternalForm());

    VBox pane = new VBox();
    pane.setSpacing(5);
    pane.getChildren().setAll(control, button);

    Scene scene = new Scene(pane);
    scene.setFill(Color.rgb(208,69,28));

    stage.setTitle("JavaFX Custom Control");
    stage.setScene(scene);
    stage.show();
}
项目:WhoWhatWhere    文件:VisualTraceUI.java   
private Spinner<Integer> createZoomSpinner(ToggleButton btnZoom, String ip)
{
    Spinner<Integer> spinnerZoom = new Spinner<>(googleMinZoomLevel, googleMaxZoomLevel, googleDefaultZoomLevel, googleZoomLevelStep);
    spinnerZoom.setPrefWidth(55);
    spinnerZoom.setPrefHeight(btnZoom.getHeight());
    spinnerZoom.valueProperty().addListener((ChangeListener<Integer>) (observable, oldValue, newValue) ->
    {
        imgService.setCenterOnIP(ip, newValue);
        labelUnderMap.setVisible(true);

        generateAndShowImage();
    });
    Tooltip spinnerTooltip = new Tooltip("Set zoom level (1-20)");
    ToolTipUtilities.setTooltipProperties(spinnerTooltip, true, GUIController.defaultTooltipMaxWidth, GUIController.defaultFontSize, null);
    spinnerZoom.setTooltip(spinnerTooltip);
    spinnerZoom.getEditor().setTooltip(spinnerTooltip);
    spinnerZoom.setEditable(false);
    spinnerZoom.setDisable(true);

    return spinnerZoom;
}
项目:markdown-writer-fx    文件:ActionUtils.java   
public static ButtonBase createToolBarButton(Action action) {
    ButtonBase button = (action.selected != null) ? new ToggleButton() : new Button();
    button.setGraphic(FontAwesomeIconFactory.get().createIcon(action.icon, "1.2em"));
    String tooltip = action.text;
    if (tooltip.endsWith("..."))
        tooltip = tooltip.substring(0, tooltip.length() - 3);
    if (action.accelerator != null)
        tooltip += " (" + action.accelerator.getDisplayText() + ')';
    button.setTooltip(new Tooltip(tooltip));
    button.setFocusTraversable(false);
    button.setOnAction(action.action);
    if (action.disable != null)
        button.disableProperty().bind(action.disable);
    if (action.selected != null)
        ((ToggleButton)button).selectedProperty().bindBidirectional(action.selected);
    return button;
}
项目:mzmine3    文件:ToggleEditor.java   
public ToggleEditor(PropertySheet.Item parameter) {
  if (!(parameter instanceof ToggleParameter))
    throw new IllegalArgumentException();

  this.toggleParameter = (ToggleParameter<ValueType>) parameter;

  // The segmented button
  this.segmentedButton = new SegmentedButton();
  segmentedButton.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK);

  // The toggle buttons
  toggleValues = this.toggleParameter.getToggleValues();
  for (ValueType toggleValue : toggleValues) {
    segmentedButton.getButtons().add(new ToggleButton(toggleValue.toString()));
  }

  // Default set to first choice
  setValue(toggleValues.get(0));

  setLeft(segmentedButton);
}
项目:mzmine3    文件:ToggleEditor.java   
@Override
public ValueType getValue() {
  ObservableList<ToggleButton> buttons = segmentedButton.getButtons();
  for (ToggleButton button : buttons) {
    if (button.isSelected()) {
      String buttonText = button.getText();

      for (ValueType toggleValue : toggleValues) {
        if (toggleValue.toString().equals(buttonText)) {
          return toggleValue;
        }
      }

    }
  }
  return null;
}
项目:mzmine3    文件:ToggleParameterSetEditor.java   
@Override
public ValueType getValue() {
  ObservableList<ToggleButton> buttons = segmentedButton.getButtons();
  for (ToggleButton button : buttons) {
    if (button.isSelected()) {
      String buttonText = button.getText();

      for (HashMap.Entry<String, ParameterSet> entry : toggleValues.entrySet()) {
        segmentedButton.getButtons().add(new ToggleButton(entry.getKey()));
        if (entry.getKey().equals(buttonText)) {
          return (ValueType) entry.getKey();
        }
      }

    }
  }
  return null;
}
项目:bco.bcozy    文件:ContextSortingPane.java   
/**
 * Constructor for a Pane with Toogle Buttons.
 * @param width width of the parent
 */
public ContextSortingPane(final double width) {

    final ToggleGroup toggleGroup = new ToggleGroup();
    final ToggleButton locationBtn = new ToggleButton("Location");
    locationBtn.setToggleGroup(toggleGroup);
    locationBtn.setMaxWidth(Double.MAX_VALUE);
    locationBtn.setPrefWidth(width / 2);
    final ToggleButton functionBtn = new ToggleButton("Function");
    functionBtn.setToggleGroup(toggleGroup);
    functionBtn.setMaxWidth(Double.MAX_VALUE);
    functionBtn.setPrefWidth(width / 2);
    //CHECKSTYLE.OFF: MultipleStringLiterals
    locationBtn.getStyleClass().addAll("visible-lg", "visible-md", "visible-sm", "visible-xs");
    functionBtn.getStyleClass().addAll("visible-lg", "visible-md", "visible-sm", "visible-xs");
    //CHECKSTYLE.ON: MultipleStringLiterals
    this.setToggleGroup(toggleGroup);
    this.getButtons().addAll(locationBtn, functionBtn);
    this.setMaxWidth(Double.MAX_VALUE);
    //this.setPrefWidth(width);
    this.setPadding(new Insets(Constants.INSETS, Constants.INSETS, Constants.INSETS, Constants.INSETS));
}
项目:org.csstudio.display.builder    文件:ToolbarHandler.java   
private ButtonBase newItem(final boolean toggle, final ToolIcons icon, final String tool_tip)
{
    final ButtonBase item = toggle ? new ToggleButton() : new Button();
    try
    {
        item.setGraphic(new ImageView(Activator.getIcon(icon.name().toLowerCase())));
    }
    catch (Exception ex)
    {
        logger.log(Level.WARNING, "Cannot get icon" + icon, ex);
        item.setText(icon.toString());
    }
    item.setTooltip(new Tooltip(tool_tip));

    toolbar.getItems().add(item);
    return item;
}