Java application not responding

35 Views Asked by At

I have made a Java application with scene builder in Java. It works fine in the preview of the scene builder in Java, but whenever I press a radio button, it remains unselected, Even after adding radio buttons, the application in the scene builder is also lagging. My project submission is so close and I am facing the same problem with each window of my project application having radio buttons. The code of my fxml file is,

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

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane prefHeight="520.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.project_oop.AImajorController">
   <children>
      <ImageView fitHeight="500.0" fitWidth="821.0" layoutX="-14.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="@nextgen_blog_default.jpg" />
         </image>
      </ImageView>
      <AnchorPane layoutX="-1.0" prefHeight="500.0" prefWidth="735.0">
         <children>
            <Label layoutX="8.0" layoutY="50.0" prefHeight="41.0" prefWidth="731.0" style="-fx-background-color: #f030c3;" text=" 1. I am interested in programming languages like Python, R, Julia, MATLAB, and Java.">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <RadioButton fx:id="a1_1" layoutX="44.0" layoutY="100.0" mnemonicParsing="false" onMouseClicked="#a1_1">
               <toggleGroup>
                  <ToggleGroup fx:id="a1" />
               </toggleGroup></RadioButton>
            <RadioButton fx:id="a1_2" layoutX="177.0" layoutY="100.0" mnemonicParsing="false" onAction="#a1_2" toggleGroup="$a1" />
            <RadioButton fx:id="a1_3" layoutX="279.0" layoutY="100.0" mnemonicParsing="false" onAction="#a1_3" toggleGroup="$a1" />
            <RadioButton fx:id="a1_4" layoutX="382.0" layoutY="100.0" mnemonicParsing="false" onAction="#a1_4" toggleGroup="$a1" />
            <RadioButton fx:id="a1_5" layoutX="500.0" layoutY="100.0" mnemonicParsing="false" onAction="#a1_5" toggleGroup="$a1" />
            <Label layoutX="8.0" layoutY="128.0" prefHeight="41.0" prefWidth="731.0" style="-fx-background-color: #eb7b4b;" text=" I enjoy working on projects that involve computer vision, natural language processing, or machine learning.">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <RadioButton fx:id="a2_4" layoutX="382.0" layoutY="183.0" mnemonicParsing="false" onAction="#a2_4" />
            <RadioButton fx:id="a2_3" layoutX="279.0" layoutY="183.0" mnemonicParsing="false" onAction="#a2_3" />
            <RadioButton fx:id="a2_2" layoutX="177.0" layoutY="183.0" mnemonicParsing="false" onAction="#a2_2" />
            <RadioButton fx:id="a2_1" layoutX="44.0" layoutY="183.0" mnemonicParsing="false" onAction="#a2_1" />
            <RadioButton fx:id="a3_1" layoutX="44.0" layoutY="257.0" mnemonicParsing="false" onAction="#a3_1" />
            <Label layoutX="10.0" layoutY="208.0" prefHeight="41.0" prefWidth="725.0" style="-fx-background-color: #77c985;" text=" I am comfortable with math and statistics.">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <Label layoutX="8.0" layoutY="291.0" prefHeight="41.0" prefWidth="731.0" style="-fx-background-color: #d1435b;" text=" I am confident that I have the ability to develop and implement machine learning algorithms.">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <Label layoutX="8.0" layoutY="447.0" prefHeight="41.0" prefWidth="731.0" />
            <Label layoutX="14.0" layoutY="23.0" text="Strongly disagree" />
            <Label layoutX="130.0" layoutY="23.0" text="Moderately Disagree" />
            <Label layoutX="271.0" layoutY="23.0" text="Agree" />
            <Label layoutX="468.0" layoutY="23.0" text="Strongly Agree" />
            <Label layoutX="342.0" layoutY="23.0" text="Moderately Agree" />
            <RadioButton fx:id="a2_5" layoutX="500.0" layoutY="183.0" mnemonicParsing="false" onAction="#a2_5" />
            <RadioButton layoutX="382.0" layoutY="344.0" mnemonicParsing="false" />
            <RadioButton layoutX="279.0" layoutY="258.0" mnemonicParsing="false" />
            <RadioButton layoutX="177.0" layoutY="258.0" mnemonicParsing="false" />
            <RadioButton layoutX="500.0" layoutY="257.0" mnemonicParsing="false" />
            <RadioButton layoutX="390.0" layoutY="459.0" mnemonicParsing="false" />
            <RadioButton layoutX="177.0" layoutY="344.0" mnemonicParsing="false" />
            <RadioButton layoutX="382.0" layoutY="257.0" mnemonicParsing="false" />
            <RadioButton layoutX="279.0" layoutY="344.0" mnemonicParsing="false" />
            <RadioButton layoutX="500.0" layoutY="344.0" mnemonicParsing="false" />
            <Label layoutX="8.0" layoutY="370.0" prefHeight="41.0" prefWidth="731.0" style="-fx-background-color: #e3d74f;" text=" For complex problems, I prefer to develop a high-level understanding of the problem before attempting a solution;  ">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <RadioButton layoutX="279.0" layoutY="459.0" mnemonicParsing="false" />
            <RadioButton layoutX="177.0" layoutY="459.0" mnemonicParsing="false" />
            <RadioButton layoutX="44.0" layoutY="344.0" mnemonicParsing="false" />
            <RadioButton layoutX="500.0" layoutY="459.0" mnemonicParsing="false" />
            <Label layoutX="8.0" layoutY="410.0" prefHeight="41.0" prefWidth="731.0" style="-fx-background-color: #e3d74f;" text="for projects, I find taking breaks and restarting with fresh ideas helpful.">
               <font>
                  <Font size="14.0" />
               </font>
            </Label>
            <Button layoutX="627.0" layoutY="463.0" mnemonicParsing="false" prefHeight="33.0" prefWidth="95.0" style="-fx-background-color: #d11528;" text="NEXT" />
            <RadioButton layoutX="52.0" layoutY="459.0" mnemonicParsing="false" />
         </children>
      </AnchorPane>
   </children>
</AnchorPane>

Code for my controller class is,

 package com.example.project_oop;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.MouseEvent;

public class AImajorController {

    @FXML
    private ToggleGroup a1;

    @FXML
    private RadioButton a1_1;

    @FXML
    private RadioButton a1_2;

    @FXML
    private RadioButton a1_3;

    @FXML
    private RadioButton a1_4;

    @FXML
    private RadioButton a1_5;

    @FXML
    private ToggleGroup a2;

    @FXML
    private RadioButton a2_1;

    @FXML
    private RadioButton a2_2;

    @FXML
    private RadioButton a2_3;

    @FXML
    private RadioButton a2_4;

    @FXML
    private RadioButton a2_5;

    @FXML
    private ToggleGroup a3;

    @FXML
    private RadioButton a3_1;

    @FXML
    private RadioButton a3_2;

    @FXML
    private RadioButton a3_3;

    @FXML
    private RadioButton a3_4;

    @FXML
    private RadioButton a3_5;

    @FXML
    private ToggleGroup a4;

    @FXML
    private RadioButton a4_1;

    @FXML
    private RadioButton a4_2;

    @FXML
    private RadioButton a4_3;

    @FXML
    private RadioButton a4_4;

    @FXML
    private RadioButton a4_5;

    @FXML
    private ToggleGroup a5;

    @FXML
    private RadioButton a5_1;

    @FXML
    private RadioButton a5_2;

    @FXML
    private RadioButton a5_3;

    @FXML
    private RadioButton a5_4;

    @FXML
    private RadioButton a5_5;

    @FXML
    void a1_1(ActionEvent event) {

    }

    @FXML
    void a1_2(ActionEvent event) {

    }

    @FXML
    void a1_3(ActionEvent event) {

    }

    @FXML
    void a1_4(ActionEvent event) {

    }

    @FXML
    void a1_5(ActionEvent event) {

    }

    @FXML
    void a2_1(ActionEvent event) {

    }

    @FXML
    void a2_2(ActionEvent event) {

    }

    @FXML
    void a2_3(ActionEvent event) {

    }

    @FXML
    void a2_4(ActionEvent event) {

    }

    @FXML
    void a2_5(ActionEvent event) {

    }

    @FXML
    void a3_1(ActionEvent event) {

    }

    @FXML
    void a3_2(ActionEvent event) {

    }

    @FXML
    void a3_3(ActionEvent event) {

    }

    @FXML
    void a3_4(ActionEvent event) {

    }

    @FXML
    void a3_5(ActionEvent event) {

    }

    @FXML
    void a4_1(ActionEvent event) {

    }

    @FXML
    void a4_2(ActionEvent event) {

    }

    @FXML
    void a4_3(ActionEvent event) {

    }

    @FXML
    void a4_4(ActionEvent event) {

    }

    @FXML
    void a4_5(ActionEvent event) {

    }

    @FXML
    void a5_1(ActionEvent event) {

    }

    @FXML
    void a5_2(ActionEvent event) {

    }

    @FXML
    void a5_3(ActionEvent event) {

    }

    @FXML
    void a5_4(ActionEvent event) {

    }

    @FXML
    void a5_5(ActionEvent event) {

    }

}

I expect the buttons to get selected but they are not being selected, In fact, the window is lagging.

0

There are 0 best solutions below