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

 
 


michael wong
How to write a simple java applet
2 Answer(s)      2 years and 6 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 :(

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 Pages:
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
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
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
Applet
Applet  Draw the class hierarchy of an Applet class. Also explain how to set background and forground colors in java
applet
applet  what is applet in java   An applet is a small program that can be sent along with a Web page to a user. Java applets can perform interactive animations, immediate calculations, or other simple tasks without
Applet
Applet  Write a Java applet that drwas a line between 2 points. The co-ordinates of 2 points should be passed as parametrs from html file. The color of the line should be red
applet - Applet
in Java Applet.",40,20); } } 2) Call this applet with html code...: http://www.roseindia.net/java/example/java/applet/ Thanks...applet   i want a simple code of applet.give me a simple example
Applet
you will see, how to write an applet program. Java source of applet...; Introduction Applet is java program that can be embedded into HTML pages. Java applets... Disadvantages of Java Applet: Java plug-in is required to run applet Java
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
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
applet - Applet
applet   how to draw textboxes using applets  Hi Friend...*; import java.awt.*; public class CreateTextBox extends Applet implements... information,visit the following link: http://www.roseindia.net/java/example/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
Simple FTP upload in Java
Simple FTP upload in Java  How to write a program for Simple FTP upload in Java? Any code example of Simple FTP upload in Java will be very helpful for me. Thanks
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
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
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
java progam - Applet
java progam  write to me java program on simple calculator  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope that it will be helpful
applet problem - Applet
applet problem  How can I create a file in client side by a java applet . Surely it will need a signed applet .But how can a signed applet create a file in the client side
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 Question
applet Question  Write a java applet to display a circle in a rectangle
applet question
applet question  Write a java applet to display a rectangle inside a circle
applet question
applet question  Write a java applet to display atriangle inside a circle
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 applet   How do I go from my applet to another JSP or HTML page
Simple Calculator Application In Java Script
Calculator The objective of this project is  learn how to write a simple calculator with the JavaScript programming language. You will learn how to write... Simple Calculator Application In Java Script  
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 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
Applet query - Applet
link: http://www.roseindia.net/java/example/java/applet/ Thanks...Applet query  i want to knw d complete detail of why does applet... with their container.It runs under the control of a Java-capable browser.The java-capable browser
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
What is Applet? - Applet
. Applet viewer is a command line program to run Java applets. It is included... any further, lets see what an applet is?http://www.roseindia.net/java/java-introduction/javatools/java_applet_viewer.shtmlThanks
Java Applet - Creating First Applet Example
Java Applet - Creating First Applet Example   ... the applet. An applet is a program written in java programming language... navigator or Internet Explorer. In this example you will see, how to write
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import... java.text.*; import java.awt.event.*; public class BoatRental extends Applet implements
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import... java.text.*; import java.awt.event.*; public class BoatRental extends Applet implements
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
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
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
Applet
Applet  Write an applet to display a string in an applet. String should be passed as a parameter to an applet
Java Program - Applet
Java Program  How to Draw various types of Charts Like pie,Line,Bar... the following links: http://www.roseindia.net/java/example/java/swing/draw-simple-bar-chart.shtml http://www.roseindia.net/java/example/java/swing/draw-pie
Top-level Listeners
; A common way to write simple applets is to use the use the applet itself... Java Notes Top-level Listeners   This is an example of top-level Listeners in Java.   In this example you will learn how to create top
Applet
Applet  Write a ava applet that sets blue color foreground and yellow color background at the start of an applet
Applet
Applet  how to run an applet on a web browser
Applet
Applet  Write a short note on applet life cycle
applet dought
applet dought  life cycle of an applet is init start and destroy but applets are executed by java enabled browsers like iexpl,so with out an object how these methods of an applet are executed
Simple Java Programs
in Java, how to write file in Java, how to copy file in Java, Java directory... learner can learn how to write first program in Java.  Java Constructor... will describe you all the steps for reading a file in Java. How to write file in Java
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
scrollbar - applet - Applet
for more information. http://www.roseindia.net/java/example/java/applet/ Thanks... scroll bar how I should give the value. I tried But not got the output. Even... ScrollbarDemo extends Applet { public void init() { Scrollbar sb = new
Java applet
Java applet  How do you set security in applets
Java applet
Java applet   How are the differences between Applets and Applications

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.