I am new to JavaFX and I tried to import the textfields and buttons from class GUI
into class Controleur
but I cannot do it. How to do it? Any answer will appreciates.
I have class GUI
:
public class GUI implements IView{
TextField textfield1;
TextField textfield2;
TextField textfield3;
TextField textfield4;
TextField textfield5;
public void View() throws Exception {
// TODO Auto-generated method stub
AnchorPane anchorPane= new AnchorPane();
textfield1.setPrefHeight(27.0);
textfield1.setPrefWidth(400.0);
textfield1.setLayoutY(109.0);
textfield1.setEditable(false);
textfield1.setAlignment(Pos.CENTER_RIGHT);
textfield1.setId("textfield1");
anchorPane.getChildren().add(textfield1);
//TextField textfield2= new TextField();
textfield2.setPrefHeight(27.0);
textfield2.setPrefWidth(400.0);
textfield2.setLayoutY(82.0);
textfield2.setEditable(false);
textfield2.setAlignment(Pos.CENTER_RIGHT);
textfield2.setId("textfield2");
anchorPane.getChildren().add(textfield2);
textfield3.setPrefHeight(27.0);
textfield3.setPrefWidth(400.0);
textfield3.setLayoutY(55.0);
textfield3.setEditable(false);
textfield3.setAlignment(Pos.CENTER_RIGHT);
textfield3.setId("textfield3");
anchorPane.getChildren().add(textfield3);
textfield4.setPrefHeight(27.0);
textfield4.setPrefWidth(400.0);
textfield4.setLayoutY(28.0);
textfield4.setEditable(false);
textfield4.setAlignment(Pos.CENTER_RIGHT);
textfield4.setId("textfield4");
anchorPane.getChildren().add(textfield4);
//TextField textfield5= new TextField();
textfield5.setPrefHeight(20.0);
textfield5.setPrefWidth(400.0);
textfield5.setLayoutY(1.0);
textfield5.setEditable(false);
textfield5.setAlignment(Pos.CENTER_RIGHT);
textfield5.setId("textfield5");
anchorPane.getChildren().add(textfield5);
Button button7 = new Button("7");
button7.setPrefHeight(34.0);
button7.setPrefWidth(82.0);
button7.setLayoutY(207.0);
button7.setLayoutX(21.0);
button7.setMnemonicParsing(false);
button7.setId("seven");
anchorPane.getChildren().add(button7);
Button button4 = new Button("4");
button4.setPrefHeight(34.0);
button4.setPrefWidth(82.0);
button4.setLayoutY(241.0);
button4.setLayoutX(21.0);
button4.setMnemonicParsing(false);
button4.setId("four");
anchorPane.getChildren().add(button4);
Button button1 = new Button("1");
button1.setPrefHeight(34.0);
button1.setPrefWidth(82.0);
button1.setLayoutY(275.0);
button1.setLayoutX(21.0);
button1.setMnemonicParsing(false);
button1.setId("one");
anchorPane.getChildren().add(button1);
Scene sc = new Scene(anchorPane, 400.0, 375.0);
}
and class Controleur
:
public class Controleur {
//code to connect with those textfields and buttons from class GUI
}