Bring components on JPanel to the front end (Java)

In VB, you can use zorder

Before you ask, no, I didn't use the layout manager in this case If you have two components on top of each other, how do you change the order after it has been displayed?

Due to the lack of space, I have a slight overlap between one button and another component (label) I add jlabel to the form before the button. When the form loads, it looks good However, when the user clicks the button, jlabel will return to the back and make a large piece disappear Is there any way to stay ahead? I have tried to label Grabfocus () is placed in the actionlistener of the button, but it doesn't work

Solution

When panels overlap on a panel, you need to tell the panel so that it can ensure that it redraws the components in zorder:

You can do this by overriding the iseptimizeddrawingenabled () method of JPanel to return false

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>