Results 1 to 4 of 4
  1. #1
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default panel wont update when repaint is called

    I am working on a chess program and its almost done. the problem i am having is that it is a network program, and moves are sent from one game to the other. when you make your move, everything works just fine. when your opponent makes a move, it doesnt appear until you click on a square. i added repaint methods to both squares(the square you move from and the square you move to), and this solved half the problem. what it did was make the piece dissappear from the square you moved from, but it still wont reappear on the square moved to. i dont know why this is happening. pieces are images stored in jlabels. I have tons of code so I didnt post any of it because my description is more helpful

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,000
    Rep Power
    10

    Default Re: panel wont update when repaint is called

    If you want help, you'll have to provide an SSCCE that demonstrates the problem. Narrow your problem down to as few lines as possible. It's a process of elimination- does it work if you take out the networking? Then you know it's not the networking. Does it work if you take out the images? Then you know it's not the images. Repeat that until you know what the problem is.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: panel wont update when repaint is called

    How do you move the piece?

    a) the easiest way is to just move the icon, then the label will repaint itself automatically

    b) if you move the label, then you need to revalidate() the panel you add the label to. Then the label will be painted automatically.

  4. #4
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default Re: panel wont update when repaint is called

    that was the answer! thank you!!!

Similar Threads

  1. Add panel to parent panel
    By LovJava in forum AWT / Swing
    Replies: 10
    Last Post: 09-02-2010, 09:43 PM
  2. while running multiple thread repaint isnt being called....
    By raptor in forum Threads and Synchronization
    Replies: 4
    Last Post: 08-26-2010, 12:47 AM
  3. Replies: 1
    Last Post: 11-02-2009, 11:39 PM
  4. update() gets never called
    By flok in forum AWT / Swing
    Replies: 8
    Last Post: 10-19-2009, 05:45 PM
  5. Repaint panel after open saved serialized array
    By King8654 in forum AWT / Swing
    Replies: 1
    Last Post: 04-24-2008, 10:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •