本文整理汇总了Java中javafx.scene.control.ToggleButton.setGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java ToggleButton.setGraphic方法的具体用法?Java ToggleButton.setGraphic怎么用?Java ToggleButton.setGraphic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ToggleButton
的用法示例。
在下文中一共展示了ToggleButton.setGraphic方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: createToggleButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createToggleButton(final ActionDescription action)
{
final ToggleButton button = new ToggleButton();
try
{
button.setGraphic(new ImageView(new Image(ResourceUtil.openPlatformResource(action.getIconResourcePath()))));
}
catch (final Exception ex)
{
logger.log(Level.WARNING, "Cannot load action icon", ex);
}
button.setTooltip(new Tooltip(action.getToolTip()));
button.setSelected(true);
button.selectedProperty()
.addListener((observable, old_value, enabled) -> action.run(this, enabled) );
return button;
}
示例4: redrawSpriteButtons
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void redrawSpriteButtons(final SpriteInfo sprite) {
ToggleButton button = spriteButtonsL.get(sprite.id);
if (button == null) {
button = spriteButtonsG.get(sprite.id);
if (button == null) throw new RuntimeException(
"Could not find sprite buttons to redraw. This cannot happen");
}
button.setGraphic(makeSpritePreview(sprite, FacingDirection.UP));
}
示例5: addImageIcon
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
*
*
* @param button
* @param icon
* @param translateX
*/
protected void addImageIcon(ToggleButton button, Icon icon, int translateX) {
ImageView image = new ImageView(this.getClass().getResource(icon.getFileName()).toString());
image.setTranslateX(translateX);
image.setFitHeight(14);
image.setFitWidth(14);
button.setGraphic(image);
}
示例6: initializeButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton initializeButton(String buttonString, Image buttonImage) {
ToggleButton toReturn = new ToggleButton(buttonString);
final NewAgentPortrait newFirmPortrait = new NewAgentPortrait(buttonImage);
toReturn.setGraphic(newFirmPortrait);
toReturn.setPrefWidth(BUTTON_SIZE);
newFirmPortrait.sizeProperty().bind(toReturn.prefWidthProperty().divide(3));
return toReturn;
}
示例7: 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;
}
示例8: createActions
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@FXThread
protected void createActions(@NotNull final HBox container) {
FXUtils.addToPane(createSaveAction(), container);
selectionButton = new ToggleButton();
selectionButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SELECTION));
selectionButton.setGraphic(new ImageView(Icons.CUBE_16));
selectionButton.setSelected(true);
selectionButton.selectedProperty().addListener((observable, oldValue, newValue) ->
changeSelectionVisible(newValue));
gridButton = new ToggleButton();
gridButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_GRID));
gridButton.setGraphic(new ImageView(Icons.PLANE_16));
gridButton.setSelected(true);
gridButton.selectedProperty().addListener((observable, oldValue, newValue) ->
changeGridVisible(newValue));
statisticsButton = new ToggleButton();
statisticsButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_STATISTICS));
statisticsButton.setGraphic(new ImageView(Icons.STATISTICS_16));
statisticsButton.setSelected(true);
statisticsButton.selectedProperty().addListener((observable, oldValue, newValue) ->
changeStatisticsVisible(newValue));
moveToolButton = new ToggleButton();
moveToolButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_MOVE_TOOL + " (G)"));
moveToolButton.setGraphic(new ImageView(Icons.MOVE_16));
moveToolButton.setSelected(true);
moveToolButton.selectedProperty().addListener((observable, oldValue, newValue) ->
updateTransformTool(TransformType.MOVE_TOOL, newValue));
rotationToolButton = new ToggleButton();
rotationToolButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_ROTATION_TOOL + " (R)"));
rotationToolButton.setGraphic(new ImageView(Icons.ROTATION_16));
rotationToolButton.selectedProperty().addListener((observable, oldValue, newValue) ->
updateTransformTool(TransformType.ROTATE_TOOL, newValue));
scaleToolButton = new ToggleButton();
scaleToolButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SCALE_TOOL + " (S)"));
scaleToolButton.setGraphic(new ImageView(Icons.SCALE_16));
scaleToolButton.selectedProperty().addListener((observable, oldValue, newValue) ->
updateTransformTool(TransformType.SCALE_TOOL, newValue));
DynamicIconSupport.addSupport(selectionButton, gridButton, statisticsButton, moveToolButton, rotationToolButton,
scaleToolButton);
FXUtils.addClassesTo(selectionButton, gridButton, statisticsButton, moveToolButton, rotationToolButton,
scaleToolButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
FXUtils.addToPane(selectionButton, container);
FXUtils.addToPane(gridButton, container);
FXUtils.addToPane(statisticsButton, container);
FXUtils.addToPane(moveToolButton, container);
FXUtils.addToPane(rotationToolButton, container);
FXUtils.addToPane(scaleToolButton, container);
}