Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Loretta Carpenter   on May 30 In Java Category.

  
Question Answered By: Tarrant Thompson   on May 30

here is an idea:
try to make images instead of icons, use the
g.drawImage function to locate those images over the
map and make a function that responds to the user
click on a x,y point, something like this:

//area:x,y,width,height
//i asume that u have various areas
int[][]
area={{20,20,20,20},{50,80,60,10},{10,10,10,10}};

//function returns the area clicked
//x,y are given by a mousemotionlistener

int usr_click(x,y){
int z=0;
while(z<area.length){
if(x>=area[z][0]&&x<=(area[z][0]+area[z][2])&&y>=area[z][1]&&x<=(area[z][0]+area\
[z][3])){
return(z);
}
z++;}
return(-1);//no area found, default  action
}

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Image processing Or get search suggestion and latest updates.


Tagged: