本文整理汇总了Java中javafx.scene.control.ToggleButton.setOnAction方法的典型用法代码示例。如果您正苦于以下问题:Java ToggleButton.setOnAction方法的具体用法?Java ToggleButton.setOnAction怎么用?Java ToggleButton.setOnAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ToggleButton
的用法示例。
在下文中一共展示了ToggleButton.setOnAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setupButton
import javafx.scene.control.ToggleButton; //导入方法依赖的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;
}
示例3: createMaximizeButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createMaximizeButton() {
ToggleButton button = new ToggleButton();
button.setId("maximizeButton");
button.setOnAction((e) -> {
JFrame frame = (JFrame) parent;
if (frame.isResizable()) {
if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == 0) {
frame.getRootPane().setBorder(BorderFactory.createEmptyBorder());
frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
} else {
frame.getRootPane().setBorder(BorderFactory.createMatteBorder(
0, 3, 3, 3,
Color.decode("#222222")));
frame.setExtendedState(JFrame.NORMAL);
}
}
});
return button;
}
示例4: addTexture
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void addTexture(final TerrainTexture tex, final boolean isGlobal) {
final Canvas preview = new Canvas(64, 32);
final GraphicsContext gc = preview.getGraphicsContext2D();
gc.setFill(tex.samplePaint);
gc.fillRect(0, 0, 64, 32);
final ToggleButton t = new ToggleButton("", preview);
t.setFocusTraversable(false);
t.setToggleGroup(toolsGroup);
t.setContextMenu(new ToolContextMenu(this, AssetType.TEXTURE, tex.id, isGlobal));
t.setOnAction(event -> {
if (t.isSelected()) canvas.setTool(new TerrainTextureTool(tex));
else canvas.setTool(null);
});
if (isGlobal) {
textures.global.getChildren().add(t);
textureButtonsG.put(tex.id, t);
} else {
textures.local.getChildren().add(t);
textureButtonsL.put(tex.id, t);
}
}
示例5: makeSpriteButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton makeSpriteButton(
final SpriteInfo sprite,
final Canvas preview,
final FacingDirection direction,
final ToolContextMenu menu
) {
final ToggleButton t = new ToggleButton("", preview);
t.setFocusTraversable(false);
t.setToggleGroup(toolsGroup);
t.setOnAction(event -> {
if (t.isSelected()) canvas.setTool(new SpriteTool(sprite, direction));
else canvas.setTool(null);
});
if (menu != null) t.setContextMenu(menu);
return t;
}
示例6: start
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
configureScene();
configureStage();
ToggleGroup tg = new ToggleGroup();
final ToggleButton tb1 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(true)).text("Not present in family").build();
tb1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if(tb1.selectedProperty().get()){
System.out.println("Selected");
}else{
System.out.println("Deselected");
}
}
});
ToggleButton tb2 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(false)).text("Not present in family").build();
// Logic starts
HBox hb = HBoxBuilder.create().spacing(15).build();
hb.getChildren().addAll(tb1,tb2);
root.getChildren().add(hb);
//ScenicView.show(scene);
}
示例7: setUpButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private void setUpButton(ToggleButton button, RelayData.State relayState) {
button.setOnAction(event -> {
if (button.isSelected()) {
setData(dataOrDefault.get().withState(relayState));
} else {
setDefaultState();
}
});
}
示例8: createFlyout
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
* Creates and returns a {@link Flyout}
* @return a new {@link Flyout}
*/
public Flyout createFlyout() {
stuffChooserTrigger = new ToggleButton("Create / Select Item");
stuffChooserTrigger.setOnAction(e -> {
if(stuffChooserTrigger.isSelected()) {
flyout.flyout();
}else{
flyout.dismiss();
}
});
Flyout retVal = new Flyout(stuffChooserTrigger, getStuffControl(), null);
return retVal;
}
示例9: createFlyout
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
* Creates and returns a {@link Flyout}
* @return a new {@link Flyout}
*/
public Flyout createFlyout() {
stuffChooserTrigger = new ToggleButton("Create / Select Item");
stuffChooserTrigger.setOnAction(e -> {
if(stuffChooserTrigger.isSelected()) {
flyout.flyout();
}else{
flyout.dismiss();
}
});
Flyout retVal = new Flyout(stuffChooserTrigger, getStuffControl());
return retVal;
}
示例10: ColorChooser
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
public ColorChooser( String initialColor,
String tooltipText ) {
this.colorPicker = new ColorPicker();
colorPicker.setTooltip( new Tooltip( tooltipText ) );
box = new HBox( 2 );
try {
colorPicker.setValue( Color.valueOf( initialColor ) );
} catch ( IllegalArgumentException e ) {
log.warn( "Unable to set color picker's initial color to invalid color: {}", initialColor );
}
manualEditor = new ManualEditor( colorPicker.getValue(), tooltipText, colorPicker::setValue );
addListener( ( observable -> {
// only update the text if the currently visible control is the color picker
if ( box.getChildren().get( 0 ) == colorPicker ) {
manualEditor.colorField.setText( colorPicker.getValue().toString() );
}
} ) );
ToggleButton editButton = AwesomeIcons.createToggleButton( AwesomeIcons.PENCIL, 10 );
box.getChildren().addAll( colorPicker, editButton );
editButton.setOnAction( event -> {
ObservableList<Node> children = box.getChildren();
if ( children.get( 0 ) == manualEditor ) {
box.getChildren().set( 0, colorPicker );
} else {
box.getChildren().set( 0, manualEditor );
manualEditor.colorField.requestFocus();
manualEditor.colorField.selectAll();
}
} );
}
示例11: createCategoryToggleButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
* This method creates a new toggle button for a given engine category.
*
* @param category The engine category, for which a new toggle button should be created
* @return The created toggle button
*/
private ToggleButton createCategoryToggleButton(EngineCategoryDTO category) {
ToggleButton categoryButton = new SidebarToggleButton(category.getName());
categoryButton.setId(String.format("%sButton", category.getName().toLowerCase()));
categoryButton.setOnAction(event -> onCategorySelection.accept(category));
return categoryButton;
}
示例12: createSettingsToggleButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
/**
* This method creates a toggle button for a given settings panel.
*
* @param item The settings panel together with its displayed name and icon css class
* @return The created toggle button
*/
private ToggleButton createSettingsToggleButton(SettingsSidebarItem item) {
ToggleButton toggleButton = new SidebarToggleButton(item.getName());
toggleButton.getStyleClass().add(item.getIconClass());
toggleButton.setOnAction(event -> onSelectSettingsItem.accept(item.getPanel()));
return toggleButton;
}
示例13: createToggleButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
private ToggleButton createToggleButton(ToggleGroup grp, String styleClass, Runnable action, String toolTip) {
ToggleButton button = new ToggleButton();
button.setToggleGroup(grp);
button.getStyleClass().add(styleClass);
button.setOnAction(evt -> {
action.run();
area.requestFocus();
});
button.setPrefWidth(25);
button.setPrefHeight(25);
if (toolTip != null) {
button.setTooltip(new Tooltip(toolTip));
}
return button;
}
示例14: getToggleButton
import javafx.scene.control.ToggleButton; //导入方法依赖的package包/类
public ToggleButton getToggleButton() {
ToggleButton toggleButton = FXUIUtils.createToggleButton(name, description);
toggleButton.setOnAction(this);
return toggleButton;
}
示例15: 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;
}