This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

to draw and remove lines on click of mouse  RSS feed

cindrella ss
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose i want to remove a line already made by previous program on a mouse event and also draw a new line at the new position where i click mouse....i added a mouse event listener class in the imagepanel but it is not working....what to do...???
i m posting the part of code where i made of the rogram is same as the previous one
class DrawingPanel extends JPanel
{ public DrawingPanel()
{MouseClickListener listener =new MouseClickListener();


public void paintComponent(Graphics g)
if (img!=null)
// resizing the JPanel to the pic size
int width = img.getWidth(this);
int height = img.getHeight(this);
imagepanel.setPreferredSize(new Dimension(width,height));
// printing the image on the panel
g.drawImage(img, 0, 0, this);


private class MouseClickListener extends MouseAdapter
{ public void MouseClicked(MouseEvent e)
{int mouseX=e.getX();
int mouseY=e.getY();
int width = img.getWidth(imagepanel);
Graphics g=imagepanel.getGraphics();

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!