Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Fonts Animation!  RSS feed

 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have placed a String in an Applet container. In default, the string has 20 px as its size. when i run the Applet, a particular character in that string should be zooming up and down. For example, we have
"javaranch" is the string in applet we have. After each minute, it has to be javaranch and back to the normal size(here 20 px). clearly, javaranch---> javaranch -----javaranch. . that should be running infinitely.

suggestions please!

thanks



 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a thread that updates the screen and then sleeps for a minute before running again. See http://java.sun.com/docs/books/tutorial/essential/concurrency/threads.html for an introduction to threads.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok. But what i am asking is, after placing a string in an applet, that string might be treated as an Image. From that image(String), how can i get the particular character? any possible ways?
in "javaranch", the particular character 'r'.


----------------------------------------------
| |
| |
| y
| |
|----- x-------- javaranch
|
|
|
| if i can get that particular char or that particular part of image means, i can do my animation part.


thanks




 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways of doing this. Either use a JLabel - that can display HTML, with which it is quite easy to display text in different font sizes. Or use Java's graphic capabilities to draw the strings "java", "r" and "anch" in different font sizes. To properly place those strings you'd need to know how big they are in the different sizes - that's where the FontMetrics class comes in handy.
 
santhosh varala kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes this can be do-a-able by two ways:
1. By Using Animated gif: Use animated gif in java where we can see directly. No need of extra threads .

2.By Using suitable fonts for that character while drawing in paint/paintComponent.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for disturbing you again!
you know the animation should be performed again and again from the first character to the last character of the string. (In "javaranch", should begin with 'j' and end with 'h'). with drawString(), i have placed that string in Applet. i am not yet cleared. It is possible with images. But i am asking that is it possible with strings?

thanks to Dittmer and santhosh
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that exactly what santhosh and I have been addressing?
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about AttributedString
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!