File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Line delete problem in jpanel on mouse clicked

supriya riya
Ranch Hand

Joined: Feb 23, 2009
Posts: 41
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: 9990
    
    7

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
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Line delete problem in jpanel on mouse clicked
 
Similar Threads
previously drawn shapes disappear when new one is created
KeyListener problem
How to shrink/grow lines
help with draw line on mouse click
Shapes return 0's as coordinates, width & height