Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Swing

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This code does not show any thing, Why?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you did with it. Did you create an appropriate HTML file naming this class in an applet tag, and open the HTML in a browser or the appletviewer application?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a Swing applet. How are you running that code, is it packaged properly, do you have a HTML web page with an applet tag, etc.? See Oracle's applet tutorial.

You should build the GUI in the Swing event dispatch thread, for example using SwingUtilities.invokeAndWait, as shown in this example.

Also, you do not need to call setVisible(true) for an applet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic