Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.awt.Dimension;

import javafx.geometry.Bounds;
import javafx.scene.Node;

public class Main {
    /**
     * Returns the dimensions of the component's layout bounds
     * @param pFxComponent
     * @return
     */
    public static Dimension getDimensionOfComponent(final Node pFxComponent) {
        return convertToDimension(pFxComponent.getLayoutBounds());
    }

    /**
     * Converts a Bound to a Dimension.  Note that some information will be
     * lost (depth, x, y, etc) yet the width and height will be preserved
     * @param pBound
     * @return
     */
    public static Dimension convertToDimension(Bounds pBound) {
        Dimension result = new Dimension();
        result.setSize(pBound.getWidth(), pBound.getHeight());
        return result;
    }
}