Finding Javafx node sizes

32
February 22, 2021, at 06:50 AM

I read somewhere that the .getWidth() function only works when the node itself is properly initiated.

I have made a class that will create a graph on a pane with given coordinates, and I need the .getWidth() property to make it work as intended. So I am wondering how and when I can properly get the actual width and height of a given node, in this case a Pane(), so I can use it to set the coordinates of for example a Circle() node.

public class Graphie extends Pane {
    public Graphie(){
        setStyle("-fx-background-color: rgb(30, 30, 32)");
        setMinSize(400, 300);
        setMaxSize(800, 600);
    }
    public void addElementCircle(float xVal, double yVal, float maxYval, int intervalRange, int size){
        Circle c = new Circle(size);
        c.setStyle("-fx-fill: rgb(255, 255, 255)");
        System.out.println(getWidth());
        getChildren().add(c);
    }
}

This is an example of that class. I am trying to get the getWidth() and getHeight() to properly give me the values (that are limited to whats in the constructor).

Any idea why the result I get always is 0.0 even when it is initialized? Or do the whole program need to compile before I do anything?

READ ALSO
NodeJs Telegram bot on VPS, need help switching to webhook

NodeJs Telegram bot on VPS, need help switching to webhook

please, help me understand how to switch my Telegram bot from polling to webhookI have a VPS server where my bot is deployed

27
I have problem with IE11 in Grid. I uploaded my code. It work fine in chrome and firefox [closed]

I have problem with IE11 in Grid. I uploaded my code. It work fine in chrome and firefox [closed]

Want to improve this question? Add details and clarify the problem by editing this post

30
Does the usage of FLAG_SECURE with respect to activity's window blocks the user triggered foreground screenshots too?

Does the usage of FLAG_SECURE with respect to activity's window blocks the user triggered foreground screenshots too?

I m using a web view wherein my pages are renderedI want to apply FLAG_SECURE on the web view

63