Review the overall structure of the code, and then go through each of the classe
ID: 3688339 • Letter: R
Question
Review the overall structure of the code, and then go through each of the classes and add comments and comment blocks. Your goal is to add sufficient comments so that someone unfamiliar with the code (but familiar with Java) could understand generally what is going on. At a minimum, there should be a code block above every function, and a block at the top of each Java file.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="main.MainController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<VBox spacing="20.0">
<children>
<RadioButton fx:id="employees" mnemonicParsing="false" text="Employees">
<VBox.margin>
<Insets />
</VBox.margin>
<toggleGroup>
<ToggleGroup fx:id="selection" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="managers" mnemonicParsing="false" text="Managers" toggleGroup="$selection">
<VBox.margin>
<Insets />
</VBox.margin>
</RadioButton>
<Button fx:id="createDataButton" mnemonicParsing="false" text="Create Data" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="10.0" left="30.0" right="10.0" top="30.0" />
</padding>
</VBox>
<TableView fx:id="dataTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<columns>
<TableColumn fx:id="nameColumn" prefWidth="202.0" text="Name" />
<TableColumn fx:id="salaryColumn" prefWidth="97.0" text="Salary" />
</columns>
</TableView>
</children>
</GridPane>
Explanation / Answer
This is JavaScript code to create the visible Form.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>//To create 2D shapes
<?import javafx.scene.control.Button?>//To Create Button Control
<?import javafx.scene.control.RadioButton?>//To Create Radio Button
<?import javafx.scene.control.TableColumn?>//To create table cotrol
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.ToggleGroup?>//To select One Button at a time
<?import javafx.scene.layout.ColumnConstraints?>//To set the restrictions on columns
<?import javafx.scene.layout.GridPane?>//To display controls in grid View
<?import javafx.scene.layout.RowConstraints?>// To set the restrictionon rows
<?import javafx.scene.layout.VBox?>//To keep set of controls in a single pane
//Properties of the controls
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="main.MainController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<VBox spacing="20.0">
<children>//Elements on the HBox
<RadioButton fx:id="employees" mnemonicParsing="false"
onAction="#showEmployees" text="Employees"> //On Action event handlling
<VBox.margin>
<Insets />
</VBox.margin>
<toggleGroup>
<ToggleGroup fx:id="selection" />
</toggleGroup>
</RadioButton>
//fx:id All Nodes you want to have a reference for in the Java code must have an fx:id field with //the same name as the Java controller's field it represents.
<RadioButton fx:id="managers" mnemonicParsing="false" text="Managers" toggleGroup="$selection">
<VBox.margin>
<Insets />
</VBox.margin>
</RadioButton>
<Button fx:id="createDataButton" mnemonicParsing="false" text="Create Data" />
</children>
<opaqueInsets>//To set the Control(ex:Button) properties it is used
<Insets />//Sizes are already mentioned so it is empty here
</opaqueInsets>
<padding>
<Insets bottom="10.0" left="30.0" right="10.0" top="30.0" />
</padding>
</VBox>
<TableView fx:id="dataTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<columns>
<TableColumn fx:id="nameColumn" prefWidth="202.0" text="Name" />
<TableColumn fx:id="salaryColumn" prefWidth="97.0" text="Salary" />
</columns>
</TableView>
</children>
</GridPane>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.