java togglebutton_Java ToggleButton.setId方法代码示例

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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值