• Post Reply 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

GUI and repaint()

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an issue everytime I use mouse listener to call repaint().. It keeps printing like a snapshot of the Frame over the other one, only once.. Can someone help me figure out why? I don't understand what is happening enough to troubleshoot this issues. Thank you.

Here is my whole code if you want to copy and paste to run it. The issue lies in the TileCanvas sub class

 
Joseph Cho
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
never mind.. I fixed it. It was the way I was calling repaint.

I used frame.repaint(); and it resolved my issue.
 
Joseph Cho
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I edited my code above.. using fram.repaint(); resets the page though, what I want to do, is is have it repaint the current grid which is in the TileCanvas class. but when i call just repaint().. i get a copy of the grid moved down a little painted over the original..

any ideas?
 
Joseph Cho
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind I fixed it.. I just used, frame.repaint().. and then just refilled the grid on any refresh..

Felt good to fix it. ;)
 
Marshal
Posts: 74387
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I shall move this to our GUIs forum, where we usually discuss such questions.

But why are you using a MouseListener in the first place? [Edit]I can now see why you want a MouseListener[/edit]
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jef Cho wrote:what I want to do, is is have it repaint the current grid which is in the TileCanvas class. but when i call just repaint().. i get a copy of the grid moved down a little painted over the original.


That's because you neglected to invoke the super implementation, which does the default painting of a blank background.Looks like you could benefit by going through the tutorial.
 
Joseph Cho
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh, gosh darn it. Yea I implemented a work around but for future projects I will be reading the tutorial shortly. The book im using is "Head First Java." So it really only scratches the surface on this topic.

Thanks again!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic