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

The components
Graphics components, Canvas

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

public class TheComponents extends Applet 
{
Choice SelectThis = new Choice ();

String txt;
TextField ThisTextField = new TextField (" Here the text field");

Checkbox ThisCheck = new Checkbox("Check a box:"); 

Label Label1 = new Label("label 1");

Scrollbar ThisScroll =  
new Scrollbar (Scrollbar.VERTICAL, 0, 8, -100, 100); 
		
				
public void init(){
		
Choice SelectThis1 = new Choice ();
SelectThis.addItem("Coffee");
SelectThis.addItem("Milk");
SelectThis.addItem("Sugar");
SelectThis.addItem("Water");
add (SelectThis);

add(ThisTextField);

add(ThisCheck); 

add(Label1); 
add(new Label("label 2", Label.RIGHT)); 

add(ThisScroll); 	
}

}

*/
// Extending from convas
/**
a Canvas is a graphic region where we can draw geometrical f
igures, such as a rectangle, an oval, etc ... The object g in the 
method paint() is a canvas.

Canvas class can extends from awt ( Abstract Windowing Toolkit ) 
class; as it does Graphics class (java.awt.Canvas like java.awt.Graphics)

The class Canvas contains the methods:
  public Canvas();
  public void addNotify();
  public void paint(Graphics g);

*/ 

// To run the below, comment the above. ----------------

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


public class TheComponents extends Applet { 
	public TheComponents() { 
	//setSize(100, 50);  not pertinent
	} 
	public void init() {
	//Here, we can add the  greenRectagle object.
	this.add(new GreenRectangle());
	}
	String ThisText1 = "a Canvas is a graphic region where we 
	can draw geometrical figures,";
	String ThisText2 = "such as a rectangle, an oval, etc ...";
	String ThisText3 = "The object g in the method paint is a canvas.";

	public void paint(Graphics g) { 
	g.drawRect(50, 150, 500, 100);  
	g.setColor(Color.red);
	g.drawString(ThisText1, 75,175); 
	g.drawString(ThisText2, 75,200); 
	g.drawString(ThisText3, 75,225); 
	} 
	
public class GreenRectangle extends Canvas {
	public void paint(Graphics g) {

	Dimension d = this.getSize();
	g.setColor(Color.green);
	g.fillRect(0, 10, d.width, d.height);
	//g.fillRect(100, 200, 100, 200);

	}
	public Dimension getMinimumSize() {
	return new Dimension(200, 200);  
	//return new Dimension(50, 100);  
	}

	public Dimension getPreferredSize() {
	return new Dimension(150, 100);  // The most considered.
	}

	public Dimension getMaximumSize() {
	return new Dimension(200, 400);  
	}
	}// End of class GreenRectangle 


	
	}//End of class TheComponenets

//---------------- end. ------------------



	

  
Google
Web
ScientificSentence
 




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


© Scientificsentence 2009. All rights reserved.