Is there a getComponentShape() method for Java Swing/ AWT?

user7999116 :

I'm just stepping into this huge world of designing graphic UIs, so please be patient.

I went through (some of) the (vast) documentation on the official website and I just wanted to know if there was a method that told me the shape of my JComponent.

When I do getBounds it says rectangle, does this refer to my shape?

Thanks in advance.

Thomas Fritsch :

AWT's class Component and Swing's class JComponent don't have the concept of arbitrary shapes, they just have a rectangular shape. That's why JComponent's method getBounds returns a Rectangle which is just a special case of the Shape interface.

Only class java.awt.Window has getShape and setShape methods, and of course all its subclasses (Dialog, Frame, JWindow, JDialog, JFrame, ...) also have. May be this is what you need.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=151269&siteId=1