【发布时间】:2010-11-24 17:14:43
【问题描述】:
我有一个 JLayeredPane,在 JLayeredPane 里面是一个 JInternalFrame。我需要的是 JInternalFrame 中内容窗格的边界(x 位置、y 位置、宽度、高度)。边界需要与 JLayeredPane 相关。我的问题是边框、标题栏,我不确定 JInternalFrame 的其他内容是否会影响我的计算。差了几个像素。
这是我尝试计算它的方法。此代码在 JInternalFrame 中:
Rectangle area = new Rectangle(
getX() + 2, //The x coordinate of the JInternalFrame + 2 for the border
getY() + ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane().getHeight(), //The Y position of the JinternalFrame + theheight of the title bar of the JInternalFrame
getContentPane().getWidth() - 2, //The width of the Jinternals content pane - the border of the frame
getContentPane().getHeight() //the height of the JinternalFrames content pane
);
我需要获取内部框架的内容窗格的位置。
【问题讨论】:
标签: java swing coordinates