How to write a simple java applet

How to write a simple java applet

Hi, how can i write a simple java applet, displaying text in specific colors and font style.

For example, the output will be something like : Name in red color Age in blue color Nationality in green color

Help me pls :(

View Answers

November 25, 2010 at 12:23 PM

Hi Friend,

Try the following code:

import java.awt.*;
import java.applet.*;

public class ShowsTextExample extends Applet{
 public void paint(Graphics g){
      g.setColor(Color.black); 
      g.drawString("Name:",10,10);
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  

      g.setColor(Color.red); 
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  
      g.drawString("Rose",100,10);

      g.setColor(Color.black); 
      g.drawString("Age:",10,40);
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  

      g.setColor(Color.blue); 
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  
      g.drawString("20",100,40);

      g.setColor(Color.black); 
      g.drawString("Nationality:",10,70);
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  

      g.setColor(Color.green); 
      g.setFont(new Font("Monotype Corsiva",Font.BOLD,20));  
      g.drawString("20",100,70);
 }
}

Thanks


November 30, 2010 at 1:33 PM

thank you for the code...its really work :)









Related Tutorials/Questions & Answers:
How to write a simple java applet
How to write a simple java applet   Hi, how can i write a simple java applet, displaying text in specific colors and font style. For example... ShowsTextExample extends Applet{ public void paint(Graphics g){ g.setColor
Simple java applet
Simple java applet  Create a Java applet to display your address on the screen. Use different colors for background and text   Please visit the following link: Applet Examples
Advertisements
Write a Java applet to draw cylinder and pentagon shapes.
Write a Java applet to draw cylinder and pentagon shapes.  Write a Java applet to draw cylinder and pentagon shapes
Simple Java applet that need usernam, password and textfield.
Simple Java applet that need usernam, password and textfield.  Hi. Anyone can help me on this matter: I need to create a small application that require user to login by username and password. After login, they should meet
Applet Write Files Example
Applet Write Files Example       In this section, you will learn how to write to a file from an applet. This is very simple but the security manager don't provide
Help me to write this simple java frame program
Help me to write this simple java frame program   I want to write a Java program for.... To create a frame with 4 text fields;name,street,city and pin;with suitable labels. Also add a button "OK". After enter values
Write an applet to display scrolling image in an applet window using thread.
Write an applet to display scrolling image in an applet window using thread.  Write an applet to display scrolling image in an applet window using thread
write simple java code - Java Beginners
write simple java code  Write a program that creates a simple calculator .The user enters two numbers in the text fields, Number 1 and Number 2. There are 4 buttons, labeled with ?Add?, ?Substract?, ?Multiply? and ?Divide
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
Q6 Write a java applet that displays 9 squares, one below the other. Every third square must be filled in black?
Q6 Write a java applet that displays 9 squares, one below the other. Every third square must be filled in black?  Q6 Write a java applet that displays 9 squares, one below the other. Every third square must be filled in black
Write an applet that prints "Lear Java it is useful" at the current cursor position whenever the mouse left button is clicked.
Write an applet that prints "Lear Java it is useful" at the current cursor position whenever the mouse left button is clicked.   Write an applet that prints "Lear Java it is useful" at the current cursor position whenever
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... bufferedWriter object to write in the file. For more details and examples related to How to write in File of Java Program
how to run applet - Applet
://www.roseindia.net/java/example/java/applet/ http://www.roseindia.net/java/example/java/applet/FirstApplet.shtml Hope that it will be helpful for you.Even...how to run applet   Hi everybody i am using connecting jdbc
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... to a file from Java program. To write the Java Write To File we will use two... and execute it, this will write "Hello Java" into out.txt file. While creating
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... how to write in a file."); br.close(); } catch (Exception e) { System.err.println
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
WRITE a simple JSP
WRITE a simple JSP  Write a JSP that accepts a string parameter from the browser and simply displays it back in the HTML response   Hi Friend, Try the following code:ADS_TO_REPLACE_1 1)form.jsp: <html> <form
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  how to connect database table with scrollbar in java applet
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file in Java   Hi, To create Comma separated value(CSV) file is very simple... Object to PrintWriter instance. How to create File to CSV in Java
Applet
Applet  I have a java applet that has a button. On clicking the button it should disappear and another applet should appear. How to write this code???? Also in login applet after successful login it should display admin applet
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file bufferedwriter in Java   In Java there are 2 types of class files used... for your references. How to use Bufferedwriter class in Java programs
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
java applet - Applet
java applet  wants to creat address bar on my java applet.  Hi Applet don't provide a facility to create a address bar directly. You just create a text box. In this text box if you enter any http address
loading Java Applet - Applet
loading Java Applet  Hi, I use the archive tag to download my applet into the Browser It takes too long to load. Can I do it in several steps... control the loading within the applet? thanks
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
how to write append file in Java
how to write append file in Java  How to write append file in Java... existing file should be retained when you are trying to write new contents in an existing files. For this in java program we uses WriteToFileAppend.java to be used
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
java applet - Applet
java applet  I want to close applet window which is open by another button of applet program. plz tell me!   Hi Friend, Try...://www.roseindia.net/java/example/java/applet/ Thanks
Java Applet
Java Applet  Hi, What is Java Applet and how it can be useful in development of Java programs? Can anyone tell me the url to learn Java Applet? Thanks   Hi, See the tutorial at: Applications and Applets Thanks
java - Applet
java  how to communicate to my servlet through applet.   ... this information to the servlet in the normal way. The applet pretends... is concerned, the applet is just another HTTP client. For more infomation
java applet problem - Applet
java applet problem  i was doing a program using java applet. I want to make a simple calculator. So i added four labels,textboxes. And 6 buttons... and to exit from the applet respectively.Now i want to display a message when
java - Applet
java  what is applet?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/ Thanks
java applet
java applet   I want code to implement (1) user will enter how many nodes (2)it should allow that no. of clicks and circle should be displayed at that position
how to write this program? - Java Beginners
how to write this program?  (game:scissor,rock ,paper) A program that plays the sciccor-rock-paper game.Revise the program to let the user continuously play until either the user or the computer wins more than 4 times
What is Applet in Java with Example?
What is Applet in Java with Examples? In this section we are going to learn the Applet in Java. In Java Applet are special Java program that runs on the Java enabled web browser. Applet allows the developer to create GUI
Write an applet program for displaying 3 different sentences with 3 different colors
Write an applet program for displaying 3 different sentences with 3 different colors  Write an applet program for displaying 3 different sentences with 3 different colors
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
how to import user-define package to applet - Applet
how to import user-define package to applet  how to import user-define package to applet... can u write a java coding can execute in jdk only...; public class JavaApplet extends Applet{ public static final String DATE
java applet
java applet  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
Java applet
Java applet  What tags are mandatory when creating HTML to display an applet
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
java - Applet
java  what is applet
Java - Applet Hello World
Java - Applet Hello World       This example introduces you with the Applet in Java. You will learn how to develop applet code and run in the browser. Applet
Applet
Applet  Write an applet to display a string in an applet. String should be passed as a parameter to an applet

Ads