please help me with two part I Bold it out as wrong part whi
please help me with two part
I Bold it out as wrong part which in the first part of code and the last part of it.
JAVA CODE
import java.util.List;
 import javafx.application.Application;
 import javafx.event.Event;
 import javafx.event.EventHandler;
 import javafx.geometry.Insets;
 import javafx.geometry.Pos;
 import javafx.scene.Node;
 import javafx.scene.Scene;
 import javafx.scene.control.Button;
 import javafx.scene.control.Label;
 import javafx.scene.control.TextField;
 import javafx.scene.input.MouseEvent;
 import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.HBox;
 import javafx.stage.Stage;
// class for revrse multiplication table
 public class RC_revmul extends Application
 {
// over ride nethod for setup the grid
 @Override
 public void start(Stage primaryStage)
 {
 BorderPane RCpane = new BorderPane();
 RCpane.setTop(getHbox1());
HBox RCprompt = new HBox(15);
 RCprompt.setPadding(new Insets(15, 15, 15, 15));
 RCprompt.setAlignment(Pos.TOP_CENTER);
 RCprompt.getStyleClass().add(\"hbox2\");
Label lblRCProblem = new Label(\"Enter Answer: \");
 RCprompt.getChildren().add(lblRCProblem);
TextField tfRCProblem = new TextField();
 RCprompt.getChildren().add(tfRCProblem);
 GridPane RCgridPane = setUpGrid();
 GridpaneHelper gh = new GridpaneHelper(RCgridPane); // this lane is wrong but why ?
 Button btnRCFindAnswer = new Button(\"Find problems\");
 btnRCFindAnswer.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>()
 {
@Override
 public void handle(Event arg0)
 {
   
 List<int[]> RCx = showFactors(tfRCProblem);
 for (int[] RCx1 : RCx) {
 Node node = gh.RCgetChildren()[RCx1[0]][RCx1[1]];
 node.setStyle(\"-fx-background-color: green\");
 }
 }
});
RCprompt.getChildren().add(btnRCFindAnswer);
RCpane.setCenter(RCprompt);
 RCpane.setBottom(RCgridPane);
Scene scene = new Scene(RCpane, 550, 650);
 scene.getStylesheets().add(getClass().getResource(\"application.css\").toExternalForm());
  primaryStage.setTitle(\"lab 6\");
 primaryStage.setScene(scene);
 primaryStage.show();
}
// method for grid layout
 private HBox getHbox1()
 {
 HBox RChbox = new HBox(15);
 RChbox.setPadding(new Insets(15, 15, 15, 15));
 RChbox.setAlignment(Pos.TOP_CENTER);
 RChbox.getStyleClass().add(\"hbox1\");
Label lblRCProblem = new Label(\"Reverse Multiplication Table\");
 RChbox.getChildren().add(lblRCProblem);
return RChbox;
 }
// method to setup a grid
 public GridPane setUpGrid() {
 GridPane RCpane = new GridPane();
 Label[][] RClabels = new Label[11][11];
for (int RCrow = 0; RCrow < 11; RCrow++) {
 for (int RCcol = 0; RCcol < 11; RCcol++) {
 Label RClbl = new Label();
 setUpLabel(RClbl, RCcol, RCrow);
 RClabels[RCrow][RCcol] = RClbl;
 RCpane.add(RClbl, RCcol, RCrow);
 }
 }
return RCpane;
 }
// method to setup label
 public void setUpLabel(final Label RClbl, final int RCcol, final int RCrow)
 {
 RClbl.setPrefHeight(50);
 RClbl.setPrefWidth(50);
 RClbl.setAlignment(Pos.CENTER);
 RClbl.setStyle(\"-fx-stroke-border: black; -fx-border-width: 1;\");
 String RCa = String.valueOf(RCrow);
 String RCb = String.valueOf(RCcol);
if (RCrow == 0 || RCcol == 0) {
 RClbl.getStyleClass().add(\"gridBorders\");
if (RCrow == 0) {
 RClbl.setText(RCb);
 } else if (RCcol == 0) {
 RClbl.setText(RCa);
 }
 } else {
 RClbl.setText(RCa + \" * \" + RCb);
 RClbl.getStyleClass().add(\"gridInside\");
}
 }
   
 // method to setup display factor
 public List<int[]> showFactors(TextField RCproblem)
 {
 RCFactCalc RCcalc = new RCFactCalc();
 int RCnumber = Integer.parseInt(RCproblem.getText());
 System.out.println(RCnumber);
 List<int[]> factors = RCcalc.FactFind(RCnumber, 10);
System.out.println(factors);
 return factors;
}
// main method
 public static void main(String[] args) {
 launch(args);
 }
}
////////////////////////
// import required packages
 import javafx.scene.Node;
 import javafx.scene.layout.GridPane;
// class RC_GridHelp
 public class RC_GridHelp
 {
// pane object
 GridPane RCgridPane;
//constructor
 public RC_GridHelp(GridPane RCgridPane)
 {
 this.RCgridPane = RCgridPane;
 }
// grid size
 private int RCsize()
 {
 return RCgridPane.getChildren().size();
 }
// method to get column size
 public int RCgetColumnSize()
 {
 int RCnumRows = RCgridPane.getRowConstraints().size();
 for (int Rci = 0; Rci < RCgridPane.getChildren().size(); Rci++)
 {
 Node RCchild = RCgridPane.getChildren().get(Rci);
 if (RCchild.isManaged())
 {
 int RCcolumnIndex = GridPane.getColumnIndex(RCchild);
 int columnEnd = GridPane.getColumnIndex(RCchild);
 RCnumRows = Math.max(RCnumRows, (columnEnd != GridPane.REMAINING ? columnEnd : RCcolumnIndex) + 1);
 }
 }
 return RCnumRows;
 }
// method to get row size
 public int RCgetRowSize()
 {
 int RCnumRows = RCgridPane.getRowConstraints().size();
 for (int Rci = 0; Rci < RCgridPane.getChildren().size(); Rci++) {
 Node RCchild = RCgridPane.getChildren().get(Rci);
 if (RCchild.isManaged()) {
 int RCrowIndex = GridPane.getRowIndex(RCchild);
 int RCrowEnd = GridPane.getRowIndex(RCchild);
 RCnumRows = Math.max(RCnumRows, (RCrowEnd != GridPane.REMAINING ? RCrowEnd : RCrowIndex) + 1);
 }
 }
 return RCnumRows;
 }
// mehtod to ge column childs
 public Node[] RCgetColumnChilds(int RCcolumnNo) {
 if (RCcolumnNo < RCgetRowSize())
 {
 return RCgetChildren()[RCcolumnNo];
 }
 return null;
 }
// mehtod to get row childs
 public Node[] RCgetRowChilds(int RCrowNo)
 {
 Node RCn[] = new Node[RCgetRowSize()];
 if (RCrowNo <= RCgetRowSize())
 {
 for (int Rci = 0; Rci < RCgetRowSize(); Rci++)
 {
 RCn[Rci] = RCgetColumnChilds(Rci)[RCrowNo];
 }
 return RCn;
 }
 return null;
 }
// mehtod to get child row
 public Node[] RCgetChildRowVia()
 {
 Node RCn[] = new Node[RCsize()];
 int RCcol = RCgetColumnSize();
 int RCarrIncre = 0;
 for (int Rci = 0; Rci < RCcol; Rci++)
 {
 for (Node RCn1 : RCgetRowChilds(Rci))
 {
if (RCn1 != null)
 {
 RCn[RCarrIncre] = RCn1;
 RCarrIncre++;
 }
 }
 }
 return RCn;
 }
// method to get the childs
 public Node[][] RCgetChildren() {
 Node[][] RCnodes = new Node[RCgetRowSize()][RCgetColumnSize()];
 for (Node RCnode : RCgridPane.getChildren()) {
 int RCrow = RCgridPane.getRowIndex(RCnode);
 int RCcolumn = RCgridPane.getColumnIndex(RCnode);
 RCnodes[RCrow][RCcolumn] = RCnode;
 }
 return RCnodes;
 }
// method to get the position
 public Integer RCpostion(Node RCnode, Pos RCpos) {
 if (RCnode != null) {
 switch (RCpos) {
 case RCRow:
 return RCgridPane.getRowIndex(RCnode);
 case RCColumn:
 return RCgridPane.getColumnIndex(RCnode);
 }
 }
 return null;
}
//enumerator
 enum Pos
 {
 RCRow,
 RCColumn;
 }
 }
///////////////////////////////////////////////////
import java.util.ArrayList;
 import java.util.List;
// class to compute factor
 class RCFactCalc
 {
public List<Integer> valLst = new ArrayList<Integer>();
 private int valproblem = 0;
// mehtod for finding the facts
 public List<int[]> FactFind(int valproblem, int limit)
 {
 int incval = 1;
 this.valproblem = valproblem;
 while (incval <= limit)
 {
 if (valproblem % incval == 0)
 {
 valLst.add(incval);
 }
incval++;
 }
 return funcCombi();
 }
// method for functional computation
 public List<int[]> funcCombi()
 {
 List<int[]> ValArys = new ArrayList<>();
 for (int lp = 0; lp < valLst.size(); lp++)
 {
 for (int j = 0; j < valLst.size(); j++) {
 if (valLst.get(lp) * valLst.get(j) == valproblem)
 {
 int[] inx = new int[2];
 inx[0] = valLst.get(lp);
 inx[1] = valLst.get(j);
 ValArys.add(inx);
 }
 }
 }
return ValArys;
 }
}
//application.css
/// Syntax error on tokens, delete these tokens
how to fix this part
 {
 -fx-text-alignment: center;
 }
.hbox1 {
 -fx-background-color: gray;
 }
.hbox2 {
 -fx-background-color: white;
}
.gridBorders {
 -fx-background-color: red;
 -fx-text-fill:#A3FF47;
 -fx-border-style: solid;
 -fx-border-width: 1;
 -fx-stroke-border: black;
}
.gridInside {
 -fx-background-color: gray;
 -fx-text-fill: white;
 -fx-border-style: solid;
 -fx-border-width: 1;
 -fx-stroke-border: black;
 }
.gridAnswer {
 -fx-background-color: white;
 -fx-text-fill: black;
}
Solution
Hi,
For GridpaneHelper gh = new GridpaneHelper(RCgridPane); problem, you should declare class GridpaneHelper which will initialize your GridPane object.
Until and unless you won\'t define that class this line shows you error.







