简体   繁体   中英

Components not displaying on JFrame time-to-time

I have a JFrame Gridlayout with components like buttons, JTextfields, JLabels.

Sometimes when I execute the file, I see an empty frame. So I have to maximize the screen, the components come back. and then when I go back to normal window, the components are still visible.

Sometimes when I execute the file, I see the components right away. As they should be.

Can anyone explain this phenomena?

Sounds like the items aren't getting painted or repainted at the correct time. Make sure you are not making the frame visible first and then adding components, or if you are making sure you revalidate() or repaint() after making changes to something that you have already made visible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM