This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String not getting drawn  RSS feed

 
Deepti Tewari
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,
I wanted to create a java program which will display a String
in all the fonts available on the System. (using a loop)
To achieve this I wrote 2 classes
1. AllFontsStringDrawer1
2. DrawString
AllFontsStringDrawer1 class has the main code while DrawString
has the main method to test the first class.
The problem is when I run my code A frame appears but there is
nothing written over it.
Pls. help.

code from second class


thanks in advance
Deepti
[ June 27, 2003: Message edited by: Deepti Tewari ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that swing components are not thread-safe. You should only modify a swing component on the swing event thread. You can do it simply by using a javax.swing.Timer and calling repaint() on its ActionPerformed. So instead of calling Thread.sleep(10), set the the Timer to continuously fire every 10 msecs and it should do what you expect.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the Swing / JFC / AWT forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!