i know, it not mine at all, i was just running thru a manual trying to get an idea of what i'm going for, just so other know. here's my code....
i just put that up the as an example of what i am tryign to do.Code:private class mouseImgEventHandler implements MouseListener, MouseMotionListener { //empty body of methods. public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} public void mouseDragged(MouseEvent e) {} //get X-Y location when mouse is clicked. public void mouseClicked(MouseEvent e) { int currentX = e.getX(); int currentY = e.getY(); //display X-Y on the message board. if(panelID == 1) parent.leftDisplay.setText("X: " + currentX + ", Y: " + currentY); if(panelID == 2) parent.rightDisplay.setText("X: " + currentX + ", Y: " + currentY); if(panelID == 3) parent.resultDisplay.setText("X: " + currentX + ", Y: " + currentY); //repaint(); } }
based on the x/y coordinates i get when i click the mouse, I want to draw circles..
Code:public void paintComponent(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create(); // eyes g.setColor(Color.red); g.fillOval(30, 30, 8, 8); g.fillOval(62, 30, 8, 8);
.but how do i pass the mouse coordnates to the drawing of the oval ?
and where would i incldue a line like thisCode:if(panelID == 1) parent.leftDisplay.setText("X: " + currentX + ", Y: " + currentY); // eyes g.setColor(Color.red); g.fillOval(30, 30, 8, 8); g.fillOval(62, 30, 8, 8);
...at the begginign of my mouse handler, or some where else ?Code:public void paintComponent(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create();
does that clear my idea more, i thanks you again for stopping to help. justin




Reply With Quote