help with code

Joined
Nov 1, 2008
Messages
2
Reaction score
0
see next post
HTML:
<pre>

public class Triangle3 extends Applet
	implements Runnable	{
Color myPine;
Color myBark;
Color myPurp;
Color myOran;
Color myBrick;


 public void init() {
  setBackground( Color.WHITE ); 
 }
	public void paint (Graphics g)
	{//begin method

	super.paint(g);
	
	myPine=new Color(39,101,18);
	myBark=new Color(70,35,0);
	myPurp=new Color(85,17,170);
	myOran=new Color(170,68,34);
	myBrick=new Color(119,21,00);
	
	int xs[]={75,100,125};  
	int ys[]={200,100,200};
	int pts = xs.length;
	g.setColor(myPine); 
	g.fillPolygon(xs,ys,pts);
	
	int xs1[]={67,100,133};  
	int ys1[]={260,135,260};
	int pts1 = xs1.length;
	g.setColor(myPine); 
	g.fillPolygon(xs1,ys1,pts1);
	
	int xs2[]={59,100,142};   
	int ys2[]={320,170,320};
	int pts2 = xs2.length;
	g.setColor(myPine); 
	g.fillPolygon(xs2,ys2,pts2);
	
	int xs3[]={52,100,147};     
	int ys3[]={380,205,380};
	int pts3 = xs3.length;
	g.setColor(myPine); 
	g.fillPolygon(xs3,ys3,pts3);
	
	g.setColor(myBark);   
	 g.fillRect(87,380,25,45);
    
g.setColor(Color.RED);    //present
	 g.fillRect(30,400,55,55);
		
	g.setColor(Color.BLUE);    
	 g.fillRect(30,425,55,5);	

	g.setColor(Color.BLUE);    
	 g.fillRect(55,400,5,55);	
		
	g.setColor(Color.YELLOW);    
	 g.fillRect(130,400,55,55);
		
	g.setColor(Color.RED);    
	 g.fillRect(130,425,55,5);	

	g.setColor(Color.RED);    
	 g.fillRect(155,400,5,55);	
		
    int x1[] = {100, 112, 144, 118, 128, 100, 72, 82, 46, 88 };
    int y1[] = {45, 81, 81, 99, 141, 117, 141, 99, 81, 81};
    int pts4 = x1.length;
    g.setColor(Color.YELLOW);
    g.fillPolygon(x1,y1,pts4);

	g.setColor(Color.BLUE);
	g.fillOval(100,180,15,15);
	
	g.setColor(Color.MAGENTA);
	g.fillOval(90,220,15,15);
		
	g.setColor(myPurp);
	g.fillOval(80,320,15,15);
	
	g.setColor(myOran);
	g.fillOval(115,240,15,15);

  
	g.setColor(Color.PINK);
	g.fillOval(90,160,5,5);
	
	g.setColor(Color.YELLOW);
	g.fillOval(98,168,5,5);
	
	g.setColor(Color.RED);
	g.fillOval(106,176,5,5);
	
	g.setColor(myPurp);
	g.fillOval(115,187,5,5);
	
	g.setColor(Color.BLUE);
	g.fillOval(115,230,5,5);
	
	g.setColor(Color.WHITE);
	g.fillOval(105,210,5,5);
	
	
     g.setColor(Color.GRAY); 
	 g.fillRect(250,325,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,327,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(273,325,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(274,327,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(296,325,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(297,327,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(250,338,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,339,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(265,338,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(267,339,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(288,338,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(289,339,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(311,338,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(311,339,7,10);
			
		
	
     g.setColor(Color.GRAY); 
	 g.fillRect(250,351,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,352,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(273,351,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(274,352,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(296,351,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(297,352,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(250,364,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,365,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(265,364,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(267,365,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(288,364,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(289,365,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(311,364,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(311,365,7,10);
			
			
			
			
     g.setColor(Color.GRAY); 
	 g.fillRect(250,377,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,378,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(273,377,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(274,378,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(296,377,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(297,378,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(250,390,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,391,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(265,390,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(267,391,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(288,390,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(289,391,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(311,390,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(311,391,7,10);
				
			
				
			
     g.setColor(Color.GRAY); 
	 g.fillRect(250,403,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,404,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(273,403,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(274,404,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(296,403,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(297,404,20,10);
        
		//Group 4 row 2
	 g.setColor(Color.GRAY); 
	 g.fillRect(250,417,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(252,418,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(265,417,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(267,418,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(288,417,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(289,418,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(311,417,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(311,418,7,10);
			
	g.setColor(Color.BLACK); 
	 g.fillRect(320,325,100,106);	
	
		
     g.setColor(Color.GRAY); 
	 g.fillRect(420,325,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(421,327,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(443,325,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(444,327,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(466,325,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(467,327,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(420,338,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(422,339,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(435,338,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(437,339,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(458,338,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(459,339,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(481,338,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(481,339,7,10);
			

     g.setColor(Color.GRAY); 
	 g.fillRect(420,351,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(422,352,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(443,351,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(444,352,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(466,351,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(467,352,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(420,364,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(422,365,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(435,364,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(437,365,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(458,364,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(459,365,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(481,364,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(481,365,7,10);
			
			
			
			
     g.setColor(Color.GRAY); 
	 g.fillRect(420,377,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(422,378,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(443,377,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(444,378,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(466,377,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(467,378,20,10);
			
	 g.setColor(Color.GRAY); 
	 g.fillRect(420,390,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(422,391,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(435,390,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(437,391,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(458,390,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(459,391,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(481,390,9,14);	
	 g.setColor(myBrick);
	 g.fillRect(481,391,7,10);
				
			
				
			
     g.setColor(Color.GRAY); 
	 g.fillRect(420,403,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(421,404,20,10); 
	 
	 g.setColor(Color.GRAY); 
	 g.fillRect(443,403,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(444,404,20,10);
	
	 g.setColor(Color.GRAY); 
	 g.fillRect(466,403,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(467,404,20,10);
        
		//Group 8 row 2
	 g.setColor(Color.GRAY); 
	 g.fillRect(420,417,24,14);	
	 g.setColor(myBrick);  
	 g.fillRect(422,418,20,10); 
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(435,417,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(437,418,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(458,417,24,14);	
	 g.setColor(myBrick); 
	 g.fillRect(459,418,20,10);
		
	 g.setColor(Color.GRAY); 
	 g.fillRect(481,417,9,14);	
	 g.setColor(myBrick); 
	 g.fillRect(481,418,7,10);
				
		
		
		
	g.setColor(Color.DARK_GRAY); 
	 g.fillRect(250,300,240,25);	
		
		
		g.setColor(Color.YELLOW); 
    g.fillArc(249,270,60,60,180,180);
	
	g.setColor(Color.DARK_GRAY); 
    g.fillArc(253,275,50,50,180,180);
	
	
	g.setColor(Color.YELLOW);  
    g.fillArc(310,270,60,60,180,180);
	
		g.setColor(Color.DARK_GRAY); 
    g.fillArc(315,275,50,50,180,180);
	
	g.setColor(Color.YELLOW);
    g.fillArc(370,270,60,60,180,180);
	
	
	g.setColor(Color.DARK_GRAY); 
    g.fillArc(375,275,50,50,180,180);
	
		g.setColor(Color.YELLOW);
    g.fillArc(430,270,60,60,180,180);
		
	g.setColor(Color.DARK_GRAY); 
    g.fillArc(435,275,50,50,180,180);
    
    }

</pre>
 
Joined
Nov 1, 2008
Messages
2
Reaction score
0
additional code

couldnt fit it all. the above code works as does the code below individualy i need to use the following code modified to have the tree lights change color. i am trying to just get the code in and working before i modify it, but it isnt showing up any suggestions. I am placing the code out side the method within the main class i get no errors and the tree etc show up just not the cookie code. sorry had to remove the comments or it wouldnt fit
HTML:
<pre>
  Font f = new Font("TimesRoman", Font.BOLD, 48);
    Color colors[] = new Color[50];
    Thread runner;

    public void start() {
        if (runner == null) {
            runner = new Thread(this);
            runner.start();
        }
    }

    public void stop() {
        if (runner != null) {
            runner.stop();
            runner = null;
        }
    }

    public void run() {

        // initialize the color array
        float c = 0;
        for (int i = 0; i < colors.length; i++) {
            colors[i] =
            Color.getHSBColor(c, (float)1.0,(float)1.0);
            c += .01;
        }

        // cycle through the colors
        int i = 0;
        while (true) {
            setForeground(colors[i]);
            repaint();

            i++;
            try { Thread.sleep(400); }
            catch (InterruptedException e) { }
            if (i == colors.length ) i = 0;
        }
    }

    public void paint2(Graphics r) {
        r.setFont(f);
        r.drawString("Look to the Cookie!", 15, 50);
    }

    public void update(Graphics r) {
        paint(r);
    }
}//end class
</pre>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top