Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Line delete problem in jpanel on mouse clicked

 
supriya riya
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic