package javafxtemplate1;
//textProperty().addListener Listview Label
import java.util.Scanner;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
final TextArea txtArea = new TextArea();
Label label1 = new Label("Enter your name");
String str1=""; static int myint;
String newLine = "\n";
@Override
public void start(Stage primaryStage) throws Exception {
//
//
Group groot1 = new Group();
Group groot2 = new Group();
//
label1.setLayoutX(10);label1.setLayoutY(20);
label1.setText("you entred : " + String.valueOf(myint));
txtArea.setMinHeight(300);
javarecursions(myint, 0, 1, 2);
txtArea.appendText("----"+newLine);
BorderPane bpane = new BorderPane();
groot1.getChildren().addAll(label1);
groot2.getChildren().addAll(txtArea);
//groot2.getChildren().addAll(scrollPane);
bpane.setCenter(groot2);
bpane.setTop(groot1);
//Scene scene = new Scene(groot, 350, 150);
Scene scene = new Scene(bpane, 350, 250);
primaryStage.setScene(scene);
primaryStage.setTitle("Recursion::comandline to TextArea");
primaryStage.show();
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("enter an integer");
myint = keyboard.nextInt();
launch(args);
}
private void javarecursions(int disks, int from, int to, int holder)
{
String strx1;
strx1 = Integer.toString(disks);
if (disks == 1) {
// Only one disk to be moved.
txtArea.appendText("Move disk :: "+strx1+ " from stack "+ from + "
to stack "+ to +newLine);
}
else {
// Moving all but one disk at the bottom, to the spare stack, then
// move the last-bottom disk RED, then put all three other disks on
top of it.
javarecursions(disks-1, from, holder, to);
txtArea.appendText("Move disk "+(disks)+ " from stack "+ from+" to
stack "+ to+newLine);
javarecursions(disks-1, holder, to, from);
}
}
}
/*
Convert using Integer.toString(int)
Convert using String.valueOf(int)
Convert using new Integer(int).toString()
Convert using String.format()
*/