爪哇 - JPanels控制Z序 [英] Java - control Z order of JPanels

查看:129
本文介绍了爪哇 - JPanels控制Z序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总之,我需要的是有一个背景图像在我的Java应用程序,并在某些情况下,在该图像的顶部创建一些其他图形。

In short, my need is to have a background Image in my java app, and upon some event, create some other graphics on top of that image.

我想我会用一个JPanel绘制背景图像,在我的JFrame程序开始增加,然后在某些事件上最重要的是添加其他JPanels。问题是摇摆给人的第一JPanels添加的最高Z指数,所以应该是什么我的背景显示出来的一切之上。

I was thinking I would use a JPanel to draw the background image in, add it at to my JFrame the start of program, and then add other JPanels on top of that upon certain events. The problem is Swing gives the JPanels added first the highest Z index, so what should be my background is showing up on top of everything.

有什么办法来控制JPanels的Z指数/订单,还是我会对此完全错误的?

Is there any way to control the Z index/order of the JPanels, or am I going about this completely wrong?

推荐答案

您可以使用 setComponentZOrder()来处理应用程序中的Z顺序。

You can use the setComponentZOrder() to handle Z-Order in your application.

资源:

  • JavaDoc - Container.setComponentZOrder
  • oracle.com - Mixing heavy and light components

这篇关于爪哇 - JPanels控制Z序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆