Infolet





Colorful Applet to Display Your Name: Java Program



Colorful Applet to Display Your Name: Java Program

Do you want to make a colorful java applet program with your name? Just compile and run below java applet code. Below applet code will show your name in blue text with red background.


import java.awt.*;
import java.applet.*;
 /* <applet code = "myname" width = 250 height = 200 > </applet> */

 public class myname extends Applet
 {
  public void paint(Graphics g)
  {
   setBackground(Color.red);
   setForeground(Color.blue);
   g.drawString("Your Name Here",80,80);
  }
 }

Here, in output applet, background color is red. If your want to change the background color to another color, just change code ‘setBackground(Color.red)’ to ‘setBackground(Color.< another color name >)’.

Here text color is blue. If your want to change the color of text to another color, just change code ‘setForeground(Color.blue)’ to ‘setForeground(Color.< another color name >)’.

Type your name instead of ‘Your Name Here’ in your code.

And here class name is ‘myname’. So you should save your program in name as ‘myname.java’.

Output for above code:

Colorful Applet to Display Your Name: Java Program

Learn how to compile a java program here.
Learn how to make, compile and run a java applet here.


Subscribe To Get Articles On Your Inbox!



Responses

0 Respones to "Colorful Applet to Display Your Name: Java Program"

Post a Comment

 
Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors GooglePrivacy Policy