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
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
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
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 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
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
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
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
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
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 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
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
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
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
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
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
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 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
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
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
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
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
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter and BufferedWriter. Class FileWriter: The FileWriter class is used to write... and strings. Example of how to write text to a file in java:ADS_TO_REPLACE_6 import
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  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
How to write in Binary file in Java programming language
How to write in Binary file in Java programming language  I need some help about Java programming. Please explain me "How to write in Binary file in Java programming language
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
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 to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
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 convert java Applet to Jave Frame
how to convert java Applet to Jave Frame  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to convert Java Applet to Jave Frame below this code is my applet source code
How to write file from inputstream in java
link to your query "How to Write to inputStream in Java". This is good...How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link
java applet
java applet  why java applet programs doesn't contain main method

Ads