4 Replies - 8161 Views - Last Post: 26 October 2007 - 05:28 PM Rate Topic: -----

#1 deathangel188  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 08-October 07

draw circle at random location

Posted 26 October 2007 - 01:51 PM

import java.applet.*;  
import java.awt.*;  
public class assiment5 extends Applet {  
		 String  background,  
				 border, 
				 size; 
		 public void init() { 
			background = getParameter("background");
			border = getParameter("border");

		}//init ends
		public static int RandomNumber(int lower, int upper) { 
   		int temp; 
   		if (upper < lower)  {  
	   		temp = upper; 
	   		upper = lower; 
	   		lower = temp; 
   		} 
   		if (upper == lower) { 
	   		return lower; 
   		} 
   		double rawnumber = Math.random(); 
   		int answer = (int)((rawnumber * (upper-lower)) + lower); 
   		return answer; 
		}  // end RandomNumber 


		public void paint(Graphics g) {
			int x, y;
			int width = Integer.parseInt(size);
			x = RandomNumber(25, 100); 
			y = randomNumber(25, 100);
			JFrame frame = new JFram();
			g.setColor(Color.decode(background));  
			g.fillRect(0, 0, getSize().width - 10, getSize().height - 10);  
			g.setColor(Color.decode(border));  
			g.drawRect(0, 0, getSize().width - 20, getSize().height - 20);  
			g.drawRect (1, 1, getSize().width - 30, getSize().height - 30);  
			g.drawOval(300,300,x,y);
			}
}


This is what i have so far, i'm sorry but i'm really bad at applet, can someone help me with next step
by this way show erroron this two liney = randomNumber(25, 100);
JFrame frame = new JFram();

Is This A Good Question/Topic? 0
  • +

Replies To: draw circle at random location

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: draw circle at random location

Posted 26 October 2007 - 02:34 PM

Java is a case-sensitive language, so "A" is not the same thing as "a". With that said the issue is that you just have a couple of typos. Capitalize the "R" in RandomNumber and put an "e" on the JFrame().

y = RandomNumber(25, 100);
JFrame frame = new JFrame();


Was This Post Helpful? 0
  • +
  • -

#3 deathangel188  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 08-October 07

Re: draw circle at random location

Posted 26 October 2007 - 03:46 PM

View Postjayman9, on 26 Oct, 2007 - 02:34 PM, said:

Java is a case-sensitive language, so "A" is not the same thing as "a". With that said the issue is that you just have a couple of typos. Capitalize the "R" in RandomNumber and put an "e" on the JFrame().

y = RandomNumber(25, 100);
JFrame frame = new JFrame();


JFrame frame = new JFrame();



this line still not working
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: draw circle at random location

Posted 26 October 2007 - 05:04 PM

Can you copy and paste the exact error message?

This will indicate why it is not working.
Was This Post Helpful? 0
  • +
  • -

#5 chuck87  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 07-September 07

Re: draw circle at random location

Posted 26 October 2007 - 05:28 PM

Add this
import javax.swing.*


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1