File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Line delete problem in jpanel on mouse clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

Line delete problem in jpanel on mouse clicked

supriya riya
Ranch Hand

Joined: Feb 23, 2009
Posts: 45
hi,i am able to delete line in code where there is only single line displayed.
But for multiple lines it does not repaint.even if line is deleted,it shows deleted line on panel.It prints "clicked" as coordinates match in console.Jpanel refreshes when i minimize or maximize the window and then it shows the lines without the deleted lines i.e it repaints.

Please help me with repaint or any thing i can change to get jpanel without deleted lines.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10824

I do not see any code which "deletes" any line.

You should never never call paint.
Instead use paintComponent() and the first invoke the super.paintComponent as the first line before executing your custom painting

PS. Also set the default close operation to EXIT_ON_CLOSE when you close the main frame.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

I told you yesterday you need to call super.paint(g) in the paint method. In fact, this is the exact same problem still. Please Use One Thread Per Question.

Maneesh is right about paintComponent though.

Closing this thread, we can continue in your previous one.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Line delete problem in jpanel on mouse clicked
It's not a secret anymore!