當前位置: 首頁>>代碼示例>>Java>>正文


Java ToggleGroup類代碼示例

本文整理匯總了Java中javafx.scene.control.ToggleGroup的典型用法代碼示例。如果您正苦於以下問題:Java ToggleGroup類的具體用法?Java ToggleGroup怎麽用?Java ToggleGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ToggleGroup類屬於javafx.scene.control包,在下文中一共展示了ToggleGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createRadioButton

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
private RadioButton createRadioButton(final Node rect, String name, final boolean toFront, ToggleGroup tg) {
    final RadioButton radioButton = new RadioButton(name);
    radioButton.setToggleGroup(tg);
    radioButton.selectedProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (radioButton.isSelected()) {
                if (toFront) {
                    rect.toFront();
                } else {
                    rect.toBack();
                }
            }
        }
    });

    return radioButton;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:NodePropertiesSample.java

示例2: RadioButtons

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
public RadioButtons() {
    super(400,100);
    ToggleGroup tg = new ToggleGroup();
    VBox vbox = new VBox();
    vbox.setSpacing(5);
    RadioButton rb1 = new RadioButton("Hello");
    rb1.setToggleGroup(tg);

    RadioButton rb2 = new RadioButton("Bye");
    rb2.setToggleGroup(tg);
    rb2.setSelected(true);

    RadioButton rb3 = new RadioButton("Disabled");
    rb3.setToggleGroup(tg);
    rb3.setSelected(false);
    rb3.setDisable(true);

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    getChildren().add(vbox);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:23,代碼來源:RadioButtons.java

示例3: createButtonGroup

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
/**
 * Create a radio button for each String in the list, add them to the container, and bind the selected value to the
 * String property
 *
 * @param container     Container to put radio buttons in
 * @param radioBtns     List of Strings, one for each radio button
 * @param modelProperty Property to bind selected radio button's value to
 */
public static ToggleGroupValue createButtonGroup(Pane container, List<String> radioBtns, StringProperty modelProperty) {
    // Create new ToggleGroup and ToggleGroupValue for the radio buttons
    ToggleGroupValue groupValue = new ToggleGroupValue();
    ToggleGroup btnsGroup = new ToggleGroup();

    // Create a radio button for each option
    for (String s : radioBtns) {
        // Create radio button for this option
        RadioButton radioBtn = new RadioButton(s);
        radioBtn.setUserData(s);
        radioBtn.setToggleGroup(btnsGroup);

        // Add to RadioButton to the container pane and the ToggleGroupValue
        container.getChildren().add(radioBtn);
        groupValue.add(radioBtn, radioBtn.getUserData());
    }

    // Bind toggle group value to model
    modelProperty.bindBidirectional(groupValue.valueProperty());

    // Select first option
    groupValue.setValue(radioBtns.get(0));

    return groupValue;
}
 
開發者ID:scify,項目名稱:jedai-ui,代碼行數:34,代碼來源:RadioButtonHelper.java

示例4: bind

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
public void bind(final ToggleGroup toggleGroup, final String propertyName) {
    try {
        String value = props.getProperty(propertyName);
        if (value != null) {
            int selectedToggleIndex = Integer.parseInt(value);
            toggleGroup.selectToggle(toggleGroup.getToggles().get(selectedToggleIndex));
        }
    } catch (Exception ignored) {
    }
    toggleGroup.selectedToggleProperty().addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable o) {
            if (toggleGroup.getSelectedToggle() == null) {
                props.remove(propertyName);
            } else {
                props.setProperty(propertyName, Integer.toString(toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle())));
            }
        }
    });
}
 
開發者ID:comtel2000,項目名稱:mokka7,代碼行數:22,代碼來源:SessionManager.java

示例5: updateMenuItems

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
private void updateMenuItems() {
    ToggleGroup group = new ToggleGroup();
    List<MenuItem> items = new ArrayList<>();
    for (Calendar calendar : getSkinnable().getCalendars()) {
        RadioMenuItem item = new RadioMenuItem(calendar.getName());
        Rectangle icon = new Rectangle(10, 10);
        icon.setArcHeight(2);
        icon.setArcWidth(2);
        icon.getStyleClass().add(calendar.getStyle() + "-icon"); //$NON-NLS-1$
        item.setGraphic(icon);
        item.setDisable(calendar.isReadOnly());
        item.setOnAction(evt -> getSkinnable().setCalendar(calendar));
        group.getToggles().add(item);
        items.add(item);
        if (calendar.equals(getSkinnable().getCalendar())) {
            item.setSelected(true);
        }
    }

    button.getItems().setAll(items);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:22,代碼來源:CalendarSelectorSkin.java

示例6: getSecretValue

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
private SecretValue getSecretValue(ToggleGroup valueSource, String value, String generated, File file) {
    Toggle current = valueSource.getSelectedToggle();

    String secretString;
    if (current.getUserData().equals("value")) {
        secretString = value;
    } else if (current.getUserData().equals("generated")) {
        Integer numBytesToGenerate = Integer.valueOf(generated);
        // TODO: store as plain bytes?
        byte[] random = Singleton.randomGenerator.generateRandom(numBytesToGenerate);
        secretString = Base64.encodeAsString(random);
    } else {
        String path = null;
        try {
            path = file.getCanonicalPath();
            return SecretValueConverter.inferEncoding(Files.readAllBytes(Paths.get(path)), SecretType.OPAQUE);
        } catch (IOException e) {
            throw new RuntimeException("Failed to read secret from file");
        }
    }

    return new SecretValue(secretString, SecretType.OPAQUE);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:24,代碼來源:GetNewSecret.java

示例7: initMenu

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
private void initMenu() {
  recentSupport = new RecentFileMenuSupport(openRecentMenu) {
    @Override
    public List<String> load() {
      return Arrays.asList(Config.getProperty(ConfigKey.RECENT_LOCATIONS, "").split(","));
    }

    @Override
    public void save(List<String> s) {
      Config.setProperty(ConfigKey.RECENT_LOCATIONS, String.join(", ", s));
    }
  };
  recentSupport.setOnAction(this::openFile);

  ToggleGroup group = new ToggleGroup();
  for (SkinStyle style : Context.SKIN.getSkinList()) {
    RadioMenuItem item = new RadioMenuItem(style.getName());
    item.setToggleGroup(group);
    item.setOnAction(e -> Context.SKIN.changeSkin(style));
    if (Context.SKIN.currentSkin() == style) {
      item.setSelected(true);
    }
    skinMenu.getItems().add(item);
  }
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:26,代碼來源:MainFrameController.java

示例8: initItems

import javafx.scene.control.ToggleGroup; //導入依賴的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

示例9: makeDataSelector

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
/**
 * Data selector between VoogaBoolean and VoogaNumber.
 * @return
 */
private HBox makeDataSelector () {
	ToggleGroup group = new ToggleGroup();
	RadioButton number = new RadioButton("Number");
	number.setToggleGroup(group);
	number.setSelected(true);
	RadioButton bool = new RadioButton("Boolean");
	bool.setToggleGroup(group);
	number.selectedProperty().addListener( (obs, old, newVal) -> {
		container.getChildren().remove(buttons);
		if (newVal) {
			container.getChildren().add(numberSelector);
			container.getChildren().remove(boolSelector);
			chosenData = VOOGA_NUMBER;
		}
		else {
			container.getChildren().remove(numberSelector);
			container.getChildren().add(boolSelector);
			chosenData = VOOGA_BOOLEAN;
		}
		container.getChildren().add(buttons);
	});
	return GUIUtils.makeRow(number, bool);
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:28,代碼來源:PropertyBuilder.java

示例10: SessionConflictDialog

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
public SessionConflictDialog( Session scheduled, Session proposed, SessionVisuals sessionVisuals  ){
    this.rootNode.getStyleClass().add("session-conflict-dialog");

    this.sessionVisuals = sessionVisuals;

    setTitle(new Label(OTNBundle.getString("OTN.CONFLICT.SCHEDULE_CONFLICT")));

    RadioButton rbScheduled = new RadioButton(OTNBundle.getString("OTN.CONFLICT.CURRENTLY_SCHEDULED"));
    RadioButton rbProposed = new RadioButton(OTNBundle.getString("OTN.CONFLICT.PROPOSED"));

    ToggleGroup group = new ToggleGroup();
    group.getToggles().addAll(rbScheduled, rbProposed);
    group.selectToggle(rbScheduled);
    
    final VBox vBox = new VBox(
            new Label(OTNBundle.getString("OTN.CONFLICT.QUESTION")),
            sessionPane(scheduled, rbScheduled),
            sessionPane(proposed, rbProposed));
    vBox.getStyleClass().add("content");

    setContent(vBox);

    getButtons().addAll(
            createButton(OTNBundle.getString("OTN.BUTTON.CANCEL"),   () -> null),
            createButton(OTNBundle.getString("OTN.BUTTON.SCHEDULE"), () -> rbProposed.isSelected() ? proposed: scheduled));
}
 
開發者ID:gluonhq,項目名稱:javaone2016,代碼行數:27,代碼來源:SessionConflictDialog.java

示例11: impl_drawNode

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
@Override
public Node impl_drawNode() {
    try {
        vb = FXMLLoader.load(resource);
    } catch (Exception e) {
        System.out.println("message: " + e.getMessage());
        reportGetterFailure("exception thrown.");
    }
LinkedList<ToggleGroup> toggleGroups = new LinkedList<ToggleGroup>();
for(Node child: vb.getChildren())
{
toggleGroups.add(((RadioButton) child).getToggleGroup());
}
for(int i = 0; i < toggleGroups.size() - 2; i ++)
{
if(!toggleGroups.get(i).equals(toggleGroups.get(i + 1)))
{
    reportGetterFailure("failed.");
    return redRectangle;
}
}
    return retRec;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:24,代碼來源:staticPropertyLoadApp.java

示例12: setupButton

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
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;
}
 
開發者ID:ra4king,項目名稱:CircuitSim,代碼行數:17,代碼來源:CircuitSim.java

示例13: enumChoiceBox

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
private <T extends Enum> VBox enumChoiceBox(final Class<T> enumClass, final Enum currentValue) {
    final T[] values = enumClass.getEnumConstants();
    
    final List<RadioButton> buttons = new ArrayList<>();
    final ToggleGroup toggleGroup = new ToggleGroup();
    for (T value : values) {
        final RadioButton button = new RadioButton(value.toString());
        button.setToggleGroup(toggleGroup);
        button.setSelected(value.equals(currentValue));
        
        buttons.add(button);
    }

    final VBox result = new VBox();
    result.setSpacing(10.0);
    result.getChildren().addAll(buttons);

    return result;
}
 
開發者ID:ThomasDaheim,項目名稱:GPXEditor,代碼行數:20,代碼來源:GPXPreferencesUI.java

示例14: criaPainelSuperior

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
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;
}
 
開發者ID:jesuino,項目名稱:livro-javafx-pratico,代碼行數:17,代碼來源:AprendendoTransicoes.java

示例15: getActionToggleButton

import javafx.scene.control.ToggleGroup; //導入依賴的package包/類
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;
	}
 
開發者ID:qupath,項目名稱:qupath,代碼行數:20,代碼來源:QuPathGUI.java


注:本文中的javafx.scene.control.ToggleGroup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。