Pages - GamesandApps

Java Code to Create 3D Text in Motion

Here is the code for creating moving text in 3D
Compile as demo.java :-

import java.awt.*;
import javax.swing.*;


class demo extends JFrame implements Runnable
{
Thread t;
JLabel m1,m3;
Font f;
int x,z;

demo()
{
x=30;
z=30;
t = new Thread(this);
f=new Font("SanSerif",Font.BOLD,30);
m3=new JLabel("Thanks For Compiling - Maninder Pal Singh");
m1=new JLabel("Thanks For Compiling - Maninder Pal Singh");

m1.setFont(f);
m1.setForeground(Color.red);
m3.setFont(f);
m3.setForeground(Color.black);
add(m1);
add(m3);
setBackground(Color.red);
setLayout(null);
setResizable(false);
setBounds(0,0,800,100);
setLocation((Toolkit.getDefaultToolkit().getScreenSize().width-getWidth())/2,
(Toolkit.getDefaultToolkit().getScreenSize().height-getHeight())/2);
t.start();
setVisible(true);
}
public void run()
{

while(true)
{
for(x=800;x>=-605;x--)
{
z=x+3;
m1.setBounds(x,8,800,35);
m3.setBounds(z,11,800,35);
m1.setVisible(true);
try
{
Thread.sleep(25);
}
catch(Exception e)
{}
}

}
}
public static void main(String a[])
{
new demo();
}
}

Here is the Sample Output:-
Output of the 3D Text in Motion Program
Output of the 3D Text in Motion program

Feel free to ask anything about this program or any other java code. Thank you.

No comments:

Post a Comment