Do not use java.awt.Dimension just because it provides an interface similar to the one you need. As the documentation says:
The Dimensions class encapsulates the width and height of a component ... into a single object.
Component implies Java AWT Component . It seems strange to use java.awt.Dimension for anything else.
If you provide your own implementation of java.awt.Dimension , it should adhere to the same interface as the Java Runtime environment. This way you get nothing. BTW, there is no need to provide your own implementation of java.awt.Dimension , the Java Runtime environment already provides a perfect implementation.
Write your own class that can handle float values as width and height.
source share