This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

change pixel value to cell coordinate

 
alona ariel
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I change the pixel value to normall cell coordinate?

int xpos
int ypos

public void mouseClicked (MouseEvent me) {


xpos = me.getX();
ypos = me.getY();




}



public void paint(Graphics g)
{


g.drawString("("+xpos+","+ypos+")",xpos,ypos);
g.drawLine(xpos, ypos, x, y);

g.setColor(Color.blue);
g.drawString("("+xpos1+","+ypos1+")",xpos1,ypos1);
g.drawLine(xpos1, ypos1, x, y);




}
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alona ariel wrote:How can I change the pixel value to normall cell coordinate?


Cell coordinate of what? A JTable? A grid you have come up with yourself? A List? A Tree?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic