0

Hello...

I try to do like this..

But I still ther are some errors...... I don't know how I solve them

Could healp me.. please

This is my code

import javax.swing.JApplet;
import java.awt.Color;
import java.awt.Graphics;
import java.io.IOException;
import java.io.*;
import java.util.Scanner;
import java.awt.*;
import java.io.FileNotFoundException;

public class colok__ extends JApplet {
   String Colors;    
   String Font1;    
   String arm;     
   String ticks ; 
   String txts;  
   String Time; 
   String str=" Time now is :  ";  
   int hr=0;
   int min=0;
   int sec=0;
   String brid;
   int sX = 5, sY = 10 ;
   
   
   public void ree()
   {
       try 
 {

setSize(800,800);    

       
     File inputFile = new File("t.txt");  
Scanner scan =new Scanner(inputFile);    

while(scan.hasNext()){   
      scan.next();         
    scan.next();         
Colors = scan.next();     

  scan.next();         
  scan.next();         
  Font1 = scan.next();  
 
 scan.next();    
 scan.next();    
 scan.next();    
arm = scan.next(); 

scan.next();   
 scan.next();   //read the secand word
 scan.next();   //read the therd word
ticks =scan.next(); //read the coler of the arm frome the fill

//Top text: Welcome to clock animation
 scan.next();  //read the first word
 scan.next();  //read the secand word
txts= scan.nextLine();  //read unteil end line

//Initial time: 06 50 00 PM
scan.next();  //read the first word
scan.next();  //read the first word
Time= scan.nextLine();  
scan.next();
scan.next();
hr=scan.nextInt();
min=scan.nextInt();
sec=scan.nextInt();
brid=scan.next();

}
}
     // thro FileNotFoundException if file has error..
     catch( FileNotFoundException e){
         e.printStackTrace();
     }

    
       }   


    public void paint(Graphics g)
    {       
 super.paint(g);   
g.setColor(colors(Font1));          
Font formts =new Font("",Font.BOLD,12 );// formate the font
g.setFont(formts);                g.drawString(txts, 335, 80);      
g.drawString(str+Time, 350,230);    



    g.setColor(colors(ticks));  
for ticks ;
// drow the ticks
   g.fillRect(sX+330,sY+ 145,20,8 );
   g.fillRect(sX+420,sY+ 150,20,8 );
   g.fillRect(sX+380,sY+ 90,8,20 );
   g.fillRect(sX+380,sY+ 185,8,15 );


g.setColor(colors(arm));//call fincatin coler and take the coker for arm ;

            arms(2*Math.PI*sec/60, sX/2,g);
            arms(2*Math.PI*min/60, sY/3,g);
            arms(2*Math.PI*hr/12, sY*2/4,g);
            
 if (sec == 60 ){

     min++;

       }

       if (min == 60){
       hr++;
   }
        if (hr == 12){
 if(brid==("am"))

             brid = "pm";
         else
brid = "am";
        }
     sec++;
   try
      {
           Thread.sleep( (int)(  1000 ) );
 }
         catch ( InterruptedException e )
         {
 }
       repaint();

}   
        
   
// fincation coled colerto set the coler for applat;s wiil used
    Color colors (String a)
    {
        if (a.equalsIgnoreCase("green"))
            return Color.GREEN;
  if (a.equalsIgnoreCase("Black"))
            return Color.BLACK;
  if (a.equalsIgnoreCase("blue"))
            return Color.BLUE;
      if (a.equalsIgnoreCase("cyan"))
            return Color.GRAY;
          if (a.equalsIgnoreCase("Drk_Gery"))
            return Color.DARK_GRAY;
          if (a.equalsIgnoreCase("gray"))
            return Color.GRAY;
          if (a.equalsIgnoreCase("light_gry"))
            return Color.LIGHT_GRAY;
          if (a.equalsIgnoreCase("magenta"))
            return Color.MAGENTA;
            if (a.equalsIgnoreCase("orange"))
            return Color.ORANGE;
          if (a.equalsIgnoreCase("pink"))
            return Color.PINK;
          if (a.equalsIgnoreCase("red"))
            return Color.RED;

          if (a.equalsIgnoreCase("whit"))
            return Color.WHITE;

        else
            return Color.yellow;
    
    }
    public void arms(double angle , int radius , Graphics g){

    angle =angle - 0.5 *Math.PI;
    int x = (int)(radius * Math.cos(angle));
    int y = (int)(radius * Math.sin(angle));

    g.drawLine(150+radius/2, 150+radius/2,150+ radius/2 + x,150+radius/2 +y);

}
}

Edited by Nick Evan: Add code-tags

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by javaAddict
0

Edit: Sorry for the mistake post. I didn't see the names of the posters.


Also, sheehab posting just the code will not do you any good. You need to explain what it does in general, what it is supposed to do, how it behaves now, what errors do you get and at what line.

Edited by javaAddict: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.