Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Need Help with action events in controller class

3048444Nov 29 2015 — edited Nov 29 2015

Hello I have designed and programmed the game and I'm almost done i'm just having a small problem connecting my model & action events.

  1. I cant get my action event method to coordinate with my quit or close button which resides on the Home Page.

  2. I'm just trying to also connect the methods in my model to connect to my action events in my controller also.

  3. I just need a short example on what I'm doing wrong...

Thank You

Attachment available...

public class FXMLHomePageController implements Initializable {

@FXML

private Button newGameBtn;

@FXML

private Button stayBtn;

@FXML

private Button hitBtn;

@FXML

private Button dblDownBtn;

@FXML

private Button tenBetBtn;

@FXML

private Button fiftyBetBtn;

@FXML

private Button houndredBetBtn;

@FXML

private Button quitBtn;

@Override

public void initialize(URL url, ResourceBundle rb) {

@FXML

public void quitBtnAction(ActionEvent event) {

Stage stage = (Stage) quitBtn.getScene().getWindow();

stage.close();

}

}

}

<@AnchorPane id="AnchorPane" fx:id="anchorpane" prefHeight="700.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.blackjack.view.FXMLHomePageController">

<children>

  \<BorderPane layoutX="191.0" layoutY="63.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">

     \<top>

        \<HBox prefHeight="39.0" prefWidth="906.0" style="-fx-background-color: black;" BorderPane.alignment="CENTER">

           \<children>

              \<ButtonBar prefHeight="39.0" prefWidth="129.0">

                 \<HBox.margin>

                    \<Insets />

                 \</HBox.margin>

                 \<padding>

                    \<Insets right="30.0" />

                 \</padding>

                 \<buttons>

                    \<Button id="quitBtn" fx:id="quitBtn" mnemonicParsing="false" prefHeight="26.0" prefWidth="85.0" text="Quit" />

                 \</buttons>

              \</ButtonBar>

              \<ButtonBar prefHeight="39.0" prefWidth="338.0">

                \<buttons>

                    \<Button id="newGameBtn" fx:id="newG" mnemonicParsing="false" prefHeight="26.0" prefWidth="107.0" text="New Game" />

                  \<Button id="stayBtn" fx:id="stay" mnemonicParsing="false" prefHeight="26.0" text="Stay" />

                    \<Button id="hitBtn" fx:id="hit" mnemonicParsing="false" text="Hit" />

                \</buttons>

                 \<HBox.margin>

                    \<Insets left="420.0" />

                 \</HBox.margin>

              \</ButtonBar>

           \</children>\</HBox>

     \</top>

     \<center>

        \<Pane fx:id="pane" prefHeight="290.0" prefWidth="600.0" BorderPane.alignment="CENTER">

           \<children>

              \<ButtonBar layoutX="395.0" layoutY="507.0" prefHeight="40.0" prefWidth="491.0">

                \<buttons>

                    \<Button id="tenBetBtn" fx:id="tenChip" mnemonicParsing="false" text="\\$10" />

                    \<Button id="fiftyBetBtn" fx:id="fiftyChip" mnemonicParsing="false" text="\\$50" />

                    \<Button id="houndredBetBtn" fx:id="houndredChip" mnemonicParsing="false" text="\\$100" />

                \</buttons>

              \</ButtonBar>

              \<ImageView fitHeight="58.0" fitWidth="60.0" layoutX="630.0" layoutY="453.0" pickOnBounds="true" preserveRatio="true">

                 \<image>

                    \<Image url="@../../../images/10chip.png" />

                 \</image>

              \</ImageView>

              \<ImageView fitHeight="58.0" fitWidth="60.0" layoutX="726.0" layoutY="453.0" pickOnBounds="true" preserveRatio="true">

                 \<image>

                    \<Image url="@../../../images/50chip.png" />

                 \</image>

              \</ImageView>

              \<ImageView fitHeight="58.0" fitWidth="60.0" layoutX="813.0" layoutY="453.0" pickOnBounds="true" preserveRatio="true">

                 \<image>

                    \<Image url="@../../../images/100chip.png" />

                 \</image>

              \</ImageView>

              \<ImageView fitHeight="58.0" fitWidth="60.0" layoutX="40.0" layoutY="449.0" pickOnBounds="true" preserveRatio="true">

                 \<image>

                    \<Image url="@../../../images/dubDwn.png" />

                 \</image>

              \</ImageView>

              \<Button id="dblDownBtn" fx:id="dubDown" layoutX="14.0" layoutY="514.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="110.0" text="Double Down" />

           \</children>\</Pane>

     \</center>

     \<bottom>

        \<HBox prefHeight="100.0" prefWidth="200.0" style="-fx-background-color: black;" BorderPane.alignment="CENTER">

           \<children>

              \<VBox alignment="TOP\_CENTER" prefHeight="200.0" prefWidth="100.0">

                 \<children>

                    \<Label text="BANKROLL" textFill="#fffafa">

                       \<VBox.margin>

                          \<Insets left="3.0" />

                       \</VBox.margin>\</Label>

                    \<Label fx:id="bRLbl" text="\\$1000" textFill="#ebe009">

                       \<font>

                          \<Font name="Droid Sans Ethiopic Bold" size="22.0" />

                       \</font>

                       \<VBox.margin>

                          \<Insets top="5.0" />

                       \</VBox.margin>\</Label>

                 \</children>

                 \<HBox.margin>

                    \<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />

                 \</HBox.margin>

              \</VBox>

              \<VBox alignment="TOP\_CENTER" prefHeight="200.0" prefWidth="100.0">

                 \<children>

                    \<Label text="BET" textFill="#f5f4f4" />

                    \<Label text="\\$00" textFill="#8ae162">

                       \<font>

                          \<Font name="Droid Sans Ethiopic" size="22.0" />

                       \</font>

                       \<VBox.margin>

                          \<Insets top="5.0" />

                       \</VBox.margin>\</Label>

                 \</children>

                 \<opaqueInsets>

                    \<Insets />

                 \</opaqueInsets>

                 \<HBox.margin>

                    \<Insets bottom="10.0" left="300.0" right="10.0" top="10.0" />

                 \</HBox.margin>

              \</VBox>

              \<VBox alignment="TOP\_CENTER" prefHeight="200.0" prefWidth="100.0">

                 \<children>

                    \<Label text="WINS" textFill="#fcf7f7">

                       \<HBox.margin>

                          \<Insets left="295.0" />

                       \</HBox.margin>

                    \</Label>

                    \<Label text="0" textFill="#05b7e8">

                       \<VBox.margin>

                          \<Insets top="5.0" />

                       \</VBox.margin>

                       \<font>

                          \<Font name="Droid Sans Ethiopic" size="22.0" />

                       \</font>

                    \</Label>

                 \</children>

                 \<HBox.margin>

                    \<Insets bottom="10.0" left="295.0" right="10.0" top="10.0" />

                 \</HBox.margin>

              \</VBox>

           \</children>

           \<HBox.margin>

              \<Insets bottom="5.0" left="5.0" right="5.0" top="10.0" />

           \</HBox.margin>

        \</HBox>

     \</bottom>

  \</BorderPane>

</children>

</AnchorPane>

Screenshot from 2015-11-29 18:21:54.png

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2015
Added on Nov 29 2015
0 comments
623 views