MisterBirs
MisterBirs

Reputation: 111

How to create a checkbox in a button? (javafx)

How to create a checkbox in a button? If it is possible to create it through the fxml file it would be better for me, but also another option would be good.

I tried to put the CheckBox tag inside the Button tag. But it didn't work

<Button text="Write All" styleClass="smallSideButton" style="-fx-pref-width: 120px;" GridPane.rowIndex="2" GridPane.columnIndex="7">
     <CheckBox/>
</Button>

Upvotes: 1

Views: 334

Answers (1)

Przemek Krysztofiak
Przemek Krysztofiak

Reputation: 924

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.layout.StackPane?>


<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button mnemonicParsing="false" text="Button">
         <graphic>
            <CheckBox mnemonicParsing="false" text="CheckBox" />
         </graphic>
      </Button>
   </children>
</StackPane>

Upvotes: 1

Related Questions