Javascript  
 
  ScriptJava  
 
  Perl  
 
  PHP  
 
  ROR  
 
  ask us  
 

 

Applications
  1. Getting started
  2. Definitions
  3. First program
  4. Characters and Strings
  5. Object and methods
  6. Arrays and Circles
  7. Exceptions
  8. The main method
  9. Reading
  10. Writing file
  11. Vectors
  12. Stacks
  13. Map The Dictionary
  14. Lists
  15. Linked lists
  16. Collection
  17. Interfaces
  18. Scanner
  19. StringTokenizer
  20. Generics
  21. JDBC
  22. DataBase Queries
  23. JSP, The main step

Graphics

Applets
  1. Regards
  2. One Picture
  3. Calculator
  4. Random pictures
  5. Bouncing picture

Swings
  1. Buttons listeners
  2. TextFields
  3. Swing Example

JavaBeans
  1. The first step
  2. Example

Search a word:
   



© The scientific sentence. 2010

Regards: First applet
First applet              The related applet

/*
1. Introduction
The main class to import is AWT (Abstract Windowing Toolkit)which is a set 
of calasses allowing graphical interfaces. The class Graphics is a class of 
AWT.
The supper class is Applet, java.applet is a package of the class Applet.

We imort then:
import java.awt.*;
import java.applet.*;

Graphics class Methods applied on an object:
if g is an object of the class Graphics, we have:
g.drawString(a string, x value, y value);
//Dispaly a string in a certain position
g.drawLine(xA,yA,xB,yB);
//Line between the point A(xA,yA) and the point B(xB,yB).
g.drawRect(xA,yA,xD,yD)
//Rectancle (A,B,C,D), with the first and the last points.
g.drawArc(xA,yA,withRectange. lengthRectangle, 0Angle, Angle);
//draw an arc 
inside a rectangle
g.drawOval(xA,yA,xB,yB);

Two principal predefined methods:
void int() and void paint (Graphics g).

1. Initialization:
------------------
We initialize fonts, dimentions pictures ,...
Here we initialize fonts
public void init(){
The constructor Font of the class Font has 
three parameters:
font-family, font-style, and font-size, we write: 
setFont(new Font("font-familty", Font.STYLE , size));
We can have a combinaition of styles as: 
Font.ITALIC + Font.BOLD
We use geleraly  Font.ITALIC,Font.BOLD, and Font.PLAIN
}

2. Drawing
-----------
public void paint(Graphics g){
String Regards = "Regards";// seven characters
Position of each character of the string 
int [][] Position {{xR,yR}, {xe,ye} , {xg,yg} , 
{xa,ya} , {xr,yr}, {xd,yd}, {xs,ys}};
Let's set color:
g.setColor(Color.green);
//Using drawString method, we can write:
for (int i = 0;  i < Regards.length(); i++){
g.drawString(Regards.substring(i,i+1), Position[i][x], 
Position[i][y]);
Whatever x and y. Example: x = 0 and y =1.
}

2. Applet program example
*/


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

public class Regards extends Applet {

static void Display(Graphics g, String text, int x, int y)
{
	g.setFont(new Font("Bookman old style", Font.ITALIC+Font.BOLD,17));
	g.setColor( Color.blue);
	g.drawString(text,x,y);
}
public void paint (Graphics g){
String text1 = 
"The file that contains the class Regards is named: Regards.java.";
String text2 = 
"Compiled with : javac Regards.java, gives rise to : Regards.class.";
String text3 =" 
It is not an application that runs with: java Regards, command line." ;
String text4 =" 
But the browser shows Regards.class , that is the applet. " ;
Display(g, text1,100,100);
Display(g, text2,100,150);
Display(g, text3,100,200);
Display(g, text4,100,250);
}

}


  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.