本文整理匯總了Java中javafx.scene.control.ToggleGroup.selectToggle方法的典型用法代碼示例。如果您正苦於以下問題:Java ToggleGroup.selectToggle方法的具體用法?Java ToggleGroup.selectToggle怎麽用?Java ToggleGroup.selectToggle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ToggleGroup
的用法示例。
在下文中一共展示了ToggleGroup.selectToggle方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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())));
}
}
});
}
示例2: 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));
}
示例3: 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(o -> {
if (toggleGroup.getSelectedToggle() == null) {
props.remove(propertyName);
} else {
props.setProperty(propertyName, Integer.toString(toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle())));
}
});
}
示例4: PreferenceOutputPane
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
@Inject
public PreferenceOutputPane(@Named("smartRadio") PreferenceRadioButton smartRadio) {
I18nContext i18n = DefaultI18nContext.getInstance();
ToggleGroup group = new ToggleGroup();
RadioButton manualRadio = new RadioButton(i18n.i18n("Manually selected"));
manualRadio.setToggleGroup(group);
manualRadio.getStyleClass().addAll(Style.VITEM.css());
manualRadio.setId("manualRadio");
smartRadio.getStyleClass().addAll(Style.VITEM.css());
smartRadio.setToggleGroup(group);
smartRadio.setGraphic(helpIcon(DefaultI18nContext.getInstance()
.i18n("Automatically set the destination directory to the selected PDF document directory")));
smartRadio.getStyleClass().addAll(Style.WITH_HELP.css());
if (isNull(group.getSelectedToggle())) {
group.selectToggle(manualRadio);
}
getChildren().addAll(manualRadio, smartRadio);
getStyleClass().addAll(Style.CONTAINER.css());
}
示例5: ToggleButtonSample
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
public ToggleButtonSample() {
// create label to show result of selected toggle button
final Label label = new Label();
label.setStyle("-fx-font-size: 2em;");
// create 3 toggle buttons and a toogle group for them
final ToggleButton tb1 = new ToggleButton("Cat");
final ToggleButton tb2 = new ToggleButton("Dog");
final ToggleButton tb3 = new ToggleButton("Horse");
ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
@Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
if(selectedToggle!=null) {
label.setText(((ToggleButton) selectedToggle).getText());
}
else {
label.setText("...");
}
}
});
// select the first button to start with
group.selectToggle(tb1);
// add buttons and label to grid and set their positions
GridPane.setConstraints(tb1,0,0);
GridPane.setConstraints(tb2,1,0);
GridPane.setConstraints(tb3,2,0);
GridPane.setConstraints(label,0,1,3,1);
GridPane grid = new GridPane();
grid.setVgap(20);
grid.setHgap(10);
getChildren().add(grid);
grid.getChildren().addAll(tb1, tb2, tb3, label);
}
示例6: initialize
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
@Override
public void initialize(URL location, ResourceBundle resources) {
// 初始化toggle button
ToggleGroup toggleGroup = new ToggleGroup();
toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
Integer flag = (Integer) newValue.getUserData();
togglePage(flag);
} else {
toggleGroup.selectToggle(oldValue);
}
});
toggleDecompile.setToggleGroup(toggleGroup);
toggleDecompile.setUserData(1);
toggleRecompile.setToggleGroup(toggleGroup);
toggleRecompile.setUserData(2);
toggleApkSign.setToggleGroup(toggleGroup);
toggleApkSign.setUserData(3);
// 默認選擇反編譯界麵
toggleGroup.selectToggle(toggleDecompile);
// 默認不顯示打開輸出目錄按鈕
btnOpenDecompileOut.setVisible(false);
btnOpenRecompileOut.setVisible(false);
btnOpenApkSignOut.setVisible(false);
}
示例7: makeMenuBar
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
private HBox makeMenuBar() {
ToggleButton tb1 = new ToggleButton("MAIN MENU");
ToggleButton tb2 = new ToggleButton("OPTIONS");
ToggleButton tb3 = new ToggleButton("EXTRA");
tb1.setFont(FXGL.getUIFactory().newFont(18));
tb2.setFont(FXGL.getUIFactory().newFont(18));
tb3.setFont(FXGL.getUIFactory().newFont(18));
ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
tb1.setUserData(menuBody);
tb2.setUserData(makeOptionsMenu());
tb3.setUserData(makeExtraMenu());
group.selectedToggleProperty().addListener((obs, old, newToggle) -> {
if (newToggle == null) {
group.selectToggle(old);
return;
}
switchMenuTo((Node)newToggle.getUserData());
});
group.selectToggle(tb1);
HBox hbox = new HBox(10, tb1, tb2, tb3);
hbox.setAlignment(Pos.TOP_CENTER);
return hbox;
}
示例8: AddAgentsToMapTitledPane
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
public AddAgentsToMapTitledPane(GeographicalMarketPresentation geographicalMarketPresentation, ControllableGeographicalScenario scenario) {
normalSelection = new ToggleButton(SELECT_BUTTON_STRING);
addOilPump = initializeButton(ADD_FIRM_BUTTON_STRING, GeographicalFirmPortrait.OIL_IMAGE);
addHousehold = initializeButton(ADD_HOUSEHOLD_BUTTON_STRING, GeographicalCustomerPortrait.CUSTOMER_IMAGE);
mouseSelection = new ToggleGroup();
normalSelection.setToggleGroup(mouseSelection);
addOilPump.setToggleGroup(mouseSelection);
addHousehold.setToggleGroup(mouseSelection);
//default to normal selection
mouseSelection.selectToggle(normalSelection);
currentMouseMode = new SimpleObjectProperty<>(MouseMode.SELECTION);
//create the mouse mode "actuator"
mouseModeSwitcher = new MouseModeSwitcher(currentMouseMode,geographicalMarketPresentation,scenario);
//start listening
mouseSelection.selectedToggleProperty().addListener(this);
currentMouseMode.addListener(this);
//add the buttons to the accordion
HBox toggleContainer = new HBox(normalSelection,addOilPump,addHousehold);
super.setContent(toggleContainer);
super.setText(PANE_TITLE);
}
示例9: createContextMenu
import javafx.scene.control.ToggleGroup; //導入方法依賴的package包/類
private void createContextMenu() {
final Menu labelsMenu = new Menu("_Labels");
labelsMenu.getItems().addAll(newLabelMenuItem);
final Menu setDownloadLimitMenu = new Menu("Set Download Limit");
final Menu setUploadLimitMenu = new Menu("Set Upload Limit");
final ToggleGroup bandwidthAllocationGroup = new ToggleGroup();
highMenuItem.setToggleGroup(bandwidthAllocationGroup);
normalMenuItem.setToggleGroup(bandwidthAllocationGroup);
lowMenuItem.setToggleGroup(bandwidthAllocationGroup);
bandwidthAllocationGroup.selectToggle(normalMenuItem);
final Menu bandwidthAllocationMenu = new Menu("Band_width Allocation");
bandwidthAllocationMenu.getItems().addAll(highMenuItem, normalMenuItem, lowMenuItem,
new SeparatorMenuItem(), setDownloadLimitMenu, setUploadLimitMenu);
final Menu removeAndMenu = new Menu("Remove A_nd");
removeAndMenu.getItems().addAll(deleteTorrentMenuItem, deleteTorrentAndDataMenuItem, deleteDataMenuItem);
final Menu advancedMenu = new Menu("_Advanced");
advancedMenu.getItems().addAll(resetBansMenuItem, clearPeerListMenuItem, setDownloadLocationMenuItem,
setDestinationNameMenuItem, updateTorrentMenuItem);
final ContextMenu contextMenu = new ContextMenu();
contextMenu.getItems().addAll(openMenuItem, openContainingFolderMenuItem, new SeparatorMenuItem(),
copyMagnetUriMenuItem, openUrlInBrowserMenuItem, new SeparatorMenuItem(),
forceStartMenuItem, startMenuItem, pauseMenuItem, stopMenuItem, new SeparatorMenuItem(),
moveUpQueueMenuItem, moveDownQueueMenuItem, labelsMenu, new SeparatorMenuItem(),
bandwidthAllocationMenu, new SeparatorMenuItem(), removeMenuItem, removeAndMenu,
new SeparatorMenuItem(), forceRecheckMenuItem, advancedMenu, new SeparatorMenuItem(),
updateTrackerMenuItem, new SeparatorMenuItem(), propertiesMenuItem);
contextMenu.showingProperty().addListener(obs -> {});
torrentTable.setRowFactory(table -> {
final TableRow<TorrentView> tableRow = new TrackerTableRow<>();
tableRow.setContextMenu(contextMenu);
tableRow.setOnContextMenuRequested(cme -> {
final TorrentView torrentView = tableRow.getItem();
if(torrentView == null) {
contextMenu.hide();
return;
}
setupMenuStates(torrentView);
setupMenuActions(torrentView);
});
return tableRow;
});
}