Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个组件(扩展 JComponent),它将在其顶部绘制一些装饰,部分在其边界之外。
我想知道是否有一种使用自包含代码在组件外部绘制的方法(例如,我不想在父容器中进行任何绘制)。
AFAIK,没有简单的解决方案。实现此目的的一种方法是绘制容器的,如此处GlassPane所示。恕我直言,我只是修改组件的对象以更改“明显”边界,这将使您能够在组件本身上绘制“超出边界”的东西。Graphics
GlassPane
Graphics