begin process at 2010 02 10 10:00:51
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Java2D

 > TEMPORISATEUR MINUTEUR

TEMPORISATEUR MINUTEUR


 Information sur la source

Note :
Aucune note
Catégorie :Java2D Classé sous :temporisateur, minuteur Niveau :Débutant Date de création :20/10/2006 Date de mise à jour :21/10/2006 17:43:26 Vu / téléchargé :7 269 / 327

Auteur : clinpus

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Pour mon deuxieme source en JAVA j'ai voulue crée une horloge system graphic avec Jcreator pro utilisant la class Graphics2D n'hésitez pas a ecrire vos commentaire

Source

  • import java.awt.*;
  • import javax.swing.*;
  • import java.awt.geom.*;
  • import java.awt.event.*;
  • import java.lang.*;
  • import java.util.GregorianCalendar;
  • public class Minuteur
  • {
  • public static void main(String[] args)
  • {
  • DrawFrame f=new DrawFrame("Draw Frame");
  • f.show(true);
  • f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
  • }
  • }
  • class DrawFrame extends JFrame
  • {
  • static public int heigth=Toolkit.getDefaultToolkit().getScreenSize().height/2;
  • public static int width=Toolkit.getDefaultToolkit().getScreenSize().width/2;
  • GregorianCalendar gr=new GregorianCalendar();
  • public DrawFrame(String titre)
  • {
  • this.setBounds(0,0,width,heigth);
  • this.setTitle(titre);
  • this.setResizable(false);
  • Container cn=this.getContentPane();
  • DrawPanel dp=new DrawPanel();
  • Timer t=new Timer(1000,dp);
  • t.start();
  • cn.add(dp);
  • }
  • }
  • class DrawPanel extends JPanel implements ActionListener
  • {
  • private double x1=256;
  • private double y1=10;
  • private double t1;
  • private double x2=256;
  • private double y2=15;
  • private double t2;
  • private double x3=256;
  • private double y3=15;
  • private double t3;
  • public void paintComponent(Graphics g)
  • {
  • super.paintComponent(g);
  • Graphics2D gr2d=(Graphics2D)g;
  • gr2d.setColor(Color.white);
  • Ellipse2D el=new Ellipse2D.Double(81,0,350,350);
  • gr2d.fill(el);
  • gr2d.setColor(Color.black);
  • gr2d.draw(el);
  • Line2D l1=new Line2D.Double(x1,y1,el.getCenterX(),el.getCenterY());
  • gr2d.draw(l1);
  • Line2D l2=new Line2D.Double(x2,y2,el.getCenterX(),el.getCenterY());
  • gr2d.draw(l2);
  • Line2D l3=new Line2D.Double(x3,y3,el.getCenterX(),el.getCenterY());
  • gr2d.draw(l3);
  • /*Line2D l1=new Line2D.Double(0,el.getCenterY(),DrawFrame.width,el.getCenterY());
  • gr2d.draw(l1);
  • Line2D l2=new Line2D.Double(el.getCenterX(),0,el.getCenterX(),DrawFrame.heigth);
  • gr2d.draw(l2);*/
  • gr2d.setFont(new Font("Comic Sans MS",Font.BOLD,26));
  • gr2d.drawString("12",245,25);
  • gr2d.drawString("6",249,345);
  • gr2d.drawString("3",414,180);
  • gr2d.drawString("9",85,180);
  • }
  • public void actionPerformed(ActionEvent e)
  • {
  • GregorianCalendar g=new GregorianCalendar();
  • x1=256+Math.sin(t1)*165;
  • y1=175-165*Math.cos(t1);
  • t1=g.get(g.SECOND)*Math.PI/30;
  • //System.out.println(t1%(2*Math.PI));
  • x2=256+Math.sin(t2)*145;
  • y2=175-145*Math.cos(t2);
  • t2=g.get(g.MINUTE)*Math.PI/30;
  • x3=256+Math.sin(t3)*100;
  • y3=175-100*Math.cos(t3);
  • t3=g.get(g.HOUR)*5*Math.PI/30;
  • repaint();
  • }
  • }
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.lang.*;
import java.util.GregorianCalendar;
public class Minuteur
{
	public static void main(String[] args)
	{
		DrawFrame f=new DrawFrame("Draw Frame");
		f.show(true);
		f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
        

	}
        
}
class DrawFrame extends JFrame
{
	static public int heigth=Toolkit.getDefaultToolkit().getScreenSize().height/2;
    public static int width=Toolkit.getDefaultToolkit().getScreenSize().width/2;
    GregorianCalendar gr=new GregorianCalendar();
    
    public DrawFrame(String titre)
    {
    	this.setBounds(0,0,width,heigth);
    	this.setTitle(titre);
    	this.setResizable(false);
    	Container cn=this.getContentPane();
    	DrawPanel dp=new DrawPanel();
    	
    	  	
    	
    	Timer t=new Timer(1000,dp);
    	t.start();
    	
    	
    	
    	cn.add(dp);
    	    	
    }
		
}

class DrawPanel extends JPanel implements ActionListener

{
	private double x1=256;
	private double y1=10;
	private double t1;
	
	
	private double x2=256;
	private double y2=15;
	private double t2;
	
	private double x3=256;
	private double y3=15;
	private double t3;
	
	
	

	
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g); 
		
	    Graphics2D gr2d=(Graphics2D)g;
	    gr2d.setColor(Color.white);
	    
	 	
    	
    	Ellipse2D el=new Ellipse2D.Double(81,0,350,350);
    	gr2d.fill(el);
    	gr2d.setColor(Color.black);
    	    
    	gr2d.draw(el);
    	
    	Line2D l1=new Line2D.Double(x1,y1,el.getCenterX(),el.getCenterY());    	   	     	
    	gr2d.draw(l1);
    	
    	Line2D l2=new Line2D.Double(x2,y2,el.getCenterX(),el.getCenterY());    	   	     	
    	gr2d.draw(l2);
    	
    	Line2D l3=new Line2D.Double(x3,y3,el.getCenterX(),el.getCenterY());    	   	     	
    	gr2d.draw(l3);
    	
    	
    	
    	
    	/*Line2D l1=new  Line2D.Double(0,el.getCenterY(),DrawFrame.width,el.getCenterY());
    	gr2d.draw(l1);
    	
    	Line2D l2=new  Line2D.Double(el.getCenterX(),0,el.getCenterX(),DrawFrame.heigth);
    	gr2d.draw(l2);*/
    	
    	gr2d.setFont(new Font("Comic Sans MS",Font.BOLD,26));
    	gr2d.drawString("12",245,25);
    	gr2d.drawString("6",249,345);
        gr2d.drawString("3",414,180);
    	gr2d.drawString("9",85,180);
    	
    	
       	
	}
	
	public void actionPerformed(ActionEvent e)
	{
		GregorianCalendar g=new GregorianCalendar();
		
		
		x1=256+Math.sin(t1)*165;
		y1=175-165*Math.cos(t1);
		t1=g.get(g.SECOND)*Math.PI/30;
		
		//System.out.println(t1%(2*Math.PI));
			x2=256+Math.sin(t2)*145;
			y2=175-145*Math.cos(t2);
			t2=g.get(g.MINUTE)*Math.PI/30;
	
	
		x3=256+Math.sin(t3)*100;
			y3=175-100*Math.cos(t3);
			t3=g.get(g.HOUR)*5*Math.PI/30;
	
		
		
		
		
		
		
		
		repaint();
	
				
	}

	
	
	
	
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  •   Minuteur

Télécharger le zip


 Historique

21 octobre 2006 17:43:26 :
Mise a jour du code source

 Sources du même auteur

Source avec Zip CODE BARRE AVEC JAVA
Source avec Zip Source avec une capture APERCU AVANT IMPRESSION AVEC JAVA
Source avec Zip Source avec une capture AGENDA

 Sources de la même categorie

AFFICHER UNE ÉTOILE AVEC JAVA2D par 2mohamed2
TEXTE AVEC OMBRE par 2mohamed2
Source avec Zip Source avec une capture JBOXIKON PORTAGE DE BOXIKON par ulm950
Source avec Zip Source avec une capture AQUARIUM 2D AVEC DOUBLE-BUFFERING ET EN UTILISANT UNIQUEMENT... par Cornellus1985
Source avec Zip Source avec une capture JPANELTEXTEDEFILANT : FAIRE DEFILER DU TEXTE (PLUSIEURES MAN... par loloof64

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture EXTINCTION MINUTÉE par Patryk403

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,796 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales