#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2018
    Posts
    6
    Rep Power
    0

    Exclamation Adjusting Shape with JFX


    This code is suppose to have a circle change based on what the user puts as radius in the textfield. There are no errors but its not rendering correctly.

    Code:
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    import javafx.scene.control.TextField;
    import javafx.geometry.Pos;
    import javafx.scene.text.Font;
    import javafx.scene.shape.*;
    import javafx.scene.Group;
    import javafx.scene.control.Label;
    import javafx.scene.layout.GridPane;
    import javafx.geometry.HPos;
    import java.util.Scanner;
     
    public class PP4o15 extends Application {
        private Label result;
        private TextField input;
     
        public void start(Stage primaryStage) {
            int r;
            double pi= 3.14, area;
            Circle circle= new Circle(100,65,20);
            circle.setFill(null);
     
     
            Scanner q = new Scanner(System.in);
            r=q.nextInt();
            //Pi Method
            area=pi*r*r;
     
     
            Font font= new Font(18);
            input= new TextField();
            //Changed Font below
            input.setFont(new Font("Arial",30));
            input.setPrefWidth(50);
            input.setAlignment(Pos.CENTER);
     
            //Stacking input TextField ontop of circle
            //StackPane pane= new StackPane(circle);
            //pane.getChildren().addAll(circle,input);
     
            Group root= new Group(circle);
            Scene scene= new Scene(root,400,200);
     
            result = new Label("");
            result.setFont(font);
            GridPane.setHalignment(result,HPos.CENTER);
     
            primaryStage.setTitle("Enter in Radius");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
        //Create method that has return
        public void processReturn(ActionEvent event)
        {
           //Method to process return
            input.setOnAction(this::processReturn); 
        }
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2018
    Posts
    1
    Rep Power
    0
    Thanks for your sharing. I am from BangaliParibar

IMN logo majestic logo threadwatch logo seochat tools logo