scrolling text from top to bottom like powerpoint

hey guys... can anyone help me in constructing texts that scrolls in the screen... im using JFrame not applet... i'm new to this kind of language can anyone help me? plz... thnx...
[188 byte] By [dimz224a] at [2007-11-26 15:12:50]
# 1

I think I know what you mean. If you mean that you want the text to be animated in that it will move across the screen, then you can use a combination of a javax.swing.Timer and Graphics2D to achieve this.

In order to use Graphics2D, you should create a JPanel class and the following method inside it:

public void paintComponent( Graphics g )

{

Graphics2D g2d = (Graphics2D)g;

g.drawString( "Something", (int)x, (int)y );

}

Now, somewhere you will need to run a thread (in this case a Swing Timer works well) in order to change the values of x and y in some way that represents how you want the text to move around the screen.

A Swing Timer takes an integer argument for delay (before the execution begins) and an ActionListener (this is where you will define how x and y change). Here is an example of how the ActionLIstener might look.

public class Animation implements ActionListener

{

public void actionPerformed( ActionEvent e )

{

t += 0.01;

x = t;

y = 100*Math.sin( t ) + 150;

}

private double t = 0;

}

This code would make the text move from left to right in a sinusoidal path.

You should look at the API to make use of the rest of the Timer methods available to you.

pogaloga at 2007-7-8 9:03:57 > top of Java-index,Security,Cryptography...
# 2

Have a look at Chet Haase's timing framework and its demos (https://timingframework.dev.java.net/).

Also i suggest reading some parts of Chet Haase blog (http://weblogs.java.net/blog/chet/) where he explains how to get smooth animation effects, ect.

In paticular these 2 articles are related:

- http://weblogs.java.net/pub/a/today/2006/02/23/smooth-moves-solutions.html

- http://weblogs.java.net/pub/a/today/2006/03/16/time-again.html

neigora at 2007-7-8 9:03:57 > top of Java-index,Security,Cryptography...