• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String not getting drawn

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm moving this to the Swing / JFC / AWT forum...
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic