Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to write a simple java applet

Have Programming Question? Ask it here!
 
 
 


michael wong
How to write a simple java applet
2 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


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 :(


Advertisement
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... Applet{ public void paint(Graphics g){ g.setColor(Color.black
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
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 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
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 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
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... 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 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 Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java with the help of a sample Java program. After going though this tutorial you... to a file from Java program. To write the Java Write To File we will use two
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 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 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 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
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: 1)form.jsp: <html> <form name="form
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
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
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
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
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
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 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
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 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
how to get session object in simple java class??
how to get session object in simple java class??  i am fallowing...) GroupDetailsDao.java (it is also a simple java class which have the jdbc logic... into session. so, please tell me, how to get the session object (GroupPojo) in a simple
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
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 - 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
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
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 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
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 - 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 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
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
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
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
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
how to write tis java programming - Java Beginners
how to write tis java programming   Airport Transport Service...; displays the details of facility how to write tis program in java.....pls reply.... Using Transport.class and Facility.class, write a program that displays
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 a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter... and strings. Example of how to write text to a file in java: import java.io.... will make a text file by the name "out.txt" and will write "Hello Java
how to write Session Handling - Java Beginners
how to write Session Handling  can any one please help me....how to handle Sessions .. in java Programs... with example  Hi friend, Read for more information with example at: http://www.roseindia.net/servlets
how to write a english dictionary project in java
how to write a english dictionary project in java  please give me idea how to write program/source code for dictionary project
how to draw network(lines and nodes) in java - Applet
how to draw network(lines and nodes) in java  Hi, Iam doing my MSC project. I want to know, how can we draw a network(with lines and nodes, any number of lines and nodes... say 5). I also want to know how can we draw a graph
 

 

 

DMCA.com