本文整理汇总了Java中javafx.scene.control.ToggleButton.setContentDisplay方法的典型用法代码示例。如果您正苦于以下问题:Java ToggleButton.setContentDisplay方法的具体用法?Java ToggleButton.setContentDisplay怎么用?Java ToggleButton.setContentDisplay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ToggleButton
的用法示例。
在下文中一共展示了ToggleButton.setContentDisplay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createToolBarControls
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private Node createToolBarControls() {
ToggleButton agendaOnlyButton = new ToggleButton();
ToggleButton dayOnlyButton = new ToggleButton();
ToggleButton standardButton = new ToggleButton();
Text listIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.LIST);
listIcon.getStyleClass().addAll("button-icon");
agendaOnlyButton.setGraphic(listIcon);
agendaOnlyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
Text calendarIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.CALENDAR);
calendarIcon.getStyleClass().addAll("button-icon");
dayOnlyButton.setGraphic(calendarIcon);
dayOnlyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
Text standardIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.COLUMNS);
standardIcon.getStyleClass().addAll("button-icon");
standardButton.setGraphic(standardIcon);
standardButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
agendaOnlyButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.AGENDA_ONLY));
dayOnlyButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.DAY_ONLY));
standardButton.setOnAction(evt -> setDayPageLayout(DayPageLayout.STANDARD));
SegmentedButton segmentedButton = new SegmentedButton(agendaOnlyButton, standardButton, dayOnlyButton);
segmentedButton.getStyleClass().add("layout-button"); //$NON-NLS-1$
segmentedButton.visibleProperty().bind(showDayPageLayoutControlsProperty());
switch (getDayPageLayout()) {
case AGENDA_ONLY:
agendaOnlyButton.setSelected(true);
break;
case DAY_ONLY:
dayOnlyButton.setSelected(true);
break;
case STANDARD:
standardButton.setSelected(true);
break;
default:
break;
}
agendaOnlyButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_MAXIMIZE_AGENDA_LIST"))); //$NON-NLS-1$
dayOnlyButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_MAXIMIZE_DAY_VIEW"))); //$NON-NLS-1$
standardButton.setTooltip(new Tooltip(Messages.getString("DayPage.TOOLTIP_STANDARD_LAYOUT"))); //$NON-NLS-1$
ToggleButton layoutButton = new ToggleButton();
layoutButton.setTooltip(new Tooltip(Messages.getString("DayPage.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);
}
});
toolbarControls = new HBox();
toolbarControls.setSpacing(10);
updateToolBarControls(segmentedButton, layoutButton);
showLayoutButtonProperty().addListener(it -> updateToolBarControls(segmentedButton, layoutButton));
return toolbarControls;
}
示例2: buildButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton buildButton(SessionListType listType, Session session) {
ToggleButton button = new ToggleButton("", listType.getOffGraphic());
button.getStyleClass().addAll(
listType.getStyleClass(),
GlistenStyleClasses.BUTTON_FLAT,
GlistenStyleClasses.BUTTON_ROUND);
button.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
// should be a separate listener or styles are messed up
button.selectedProperty().addListener((o, ov, selected) -> {
button.setGraphic(selected ? listType.getOnGraphic() : listType.getOffGraphic());
});
// setup binding between button and appropriate list of session ids
boolean isSelected = listContains(session, listType);
button.setSelected(isSelected);
button.selectedProperty().addListener((o, ov, selected) -> {
if (button.getUserData() == LOCK) return;
if (!service.isAuthenticated()) {
boolean authenticated = service.authenticate();
if (!authenticated) {
quietUpdateBtnState(button, () -> button.setSelected(ov));
return;
}
}
// we must use the session stored in the button - not the one provided
// as an argument to the buildButton method
Session actualSession = (Session) button.getProperties().get(SESSION_KEY);
if (selected) {
// Resolve scheduling conflicts
if (listType == SessionListType.SCHEDULED) {
Optional<Session> conflictOption = findConflictingSession(actualSession);
if (conflictOption.isPresent()) {
Session conflict = conflictOption.get();
Optional<Session> dialogResult = new SessionConflictDialog(conflict, actualSession, this).showAndWait();
if (dialogResult.isPresent()) {
Session selectedSession = dialogResult.get();
if (selectedSession.equals(actualSession)) {
// It is important to preserve this order: first remove and then add because of the
// toast messages. This way "session scheduled" will be displayed.
listRemove(conflict, listType);
listAdd(actualSession, listType);
updateButton(button, true, actualSession);
} else {
button.setSelected(false);
}
} else {
button.setSelected(false);
}
} else {
listAdd(actualSession, listType);
}
} else {
listAdd(actualSession, listType);
}
} else {
listRemove(actualSession, listType);
}
});
updateButton(button, isSelected, session);
return button;
}