/* related posts with thumb nails */

Create a font animation application that changes the colors of text as and when prompted.:


import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class FontAnim extends Applet implements ActionListener

{

Button b1=new Button("Change Color");

int r=0,g=0,b=0;

public void init()

{

add(b1);

b1.addActionListener(this);

setFont(new Font("Arial",Font.BOLD,30));

}

public void actionPerformed(ActionEvent ae)

{

r=(int)(Math.random()*255);

g=(int)(Math.random()*255);

b=(int)(Math.random()*255);

repaint();

}

public void paint(Graphics gr)

{

gr.setColor(new Color(r,g,b));

gr.drawString("APOORVA",20,200);

}

}

output:


Related Topics:

0 comments:

Post a Comment