Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Line delete problem in jpanel on mouse clicked

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic