重叠AWT线和Swing的JLabel [英] Overlapping AWT lines and Swing JLabels
本文介绍了重叠AWT线和Swing的JLabel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用我行原语和 JLables
在我的应用程序有问题。我试图解释它:
I have a problem in my application using line primitives and JLables
. I try to explain it:
- 我在使用线重新present道路和
的JLabel
重新present城市绘制车辆路线。我需要使用的JLabel
的,因为每个JLabel的有一个监听器,显示与有关城市的信息的对话框。 - 我重新定义
的paint()
我的主要方法的JPanel
。在该方法中我第一次调用super.paint()
,然后我绘制线条,最后我的标签添加到的JPanel
。
- I have to draw a vehicle route using lines to represent roads and
JLabels
to represent cities. I need the use ofJLabels
because each JLabel has a Listener that shows a dialog with information about the city. - I redefine
paint()
method of my mainJPanel
. In that method I first in invoke thesuper.paint()
, then I draw the lines and finally I add the Labels to theJPanel
.
的问题是,该线重叠的标签不管无关紧要画它们的顺序。请问有什么建议吗?
The problem is that the lines overlap the labels regardless the matter the order of painting them. Is there any suggestion?
推荐答案
您还可以覆盖的paintComponent()
或 paintChildren()
的的JPanel
方法。
在 paintChildren()
打电话给你的线条绘制,然后超级
绘制的JLabel
。
You can also override paintComponent()
or paintChildren()
methods of the JPanel
.
In the paintChildren()
call your lines drawing and then super
to draw JLabels
.
这篇关于重叠AWT线和Swing的JLabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文