Java Swing: JLabel Text Not Appearing on Screen

  1. You’re mixing a GUI- with a Console-Application. Is this really what you want?
  2. You’re nulling the Layout of your JFrame. Why do you do this? You basically always need layouting. Have a look at this guide.

Your JLabel is indeed showing. Try to resize your JFrame after you typed in your name, you should see your JLabel then. The JLabel will always appear, if you call setVisible(true) at the end of your program. This is because your JFrame gets painted when you call setVisible(true). If you add another component to it, the JFrame is not repainted. If you resize it, it will be repainted.

However, you should have a look at basic Java Swing tutorials.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top