开发者

How to get x and y position of JPane in JPanel

开发者 https://www.devze.com 2023-03-13 23:21 出处:网络
I have a JEditorPane in a JPanel. I want to know how far from the left and the right the JEditorPane is from the edge of the JPanel (or the frame as they are the same).

I have a JEditorPane in a JPanel. I want to know how far from the left and the right the JEditorPane is from the edge of the JPanel (or the frame as they are the same).

Is there a way to do this?

The Reason Is: I want to put a gradient on the JEditorPane that aligns to the edge of the JPanel in stead of the JEditorPane. The reason I want to do this is because the开发者_如何学Pythonre is a gradient on the JPanel and I don't want the JEditorPane background to appear to cover up the gradient. I would set the background to transparent but I got screen paint issues that I was unable to resolve.


Just call getLocation on your JEditorPane. The location of a Component is relative to its parent.

0

精彩评论

暂无评论...
验证码 换一张
取 消