Results 1 to 4 of 4
- 11-20-2011, 10:04 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 27
- Rep Power
- 0
repaint() and revalidate() doesn't work in my JContentPane
Hi,
I have to make a game (connect4) for school. We have to use the observer-observable pattern in our game. So when I put a chip on the board the model will change and in a update() method the view of my board have to change. The observer-observable pattern is correct, because when I put my boardview in a JDIalog it opens and the new boardview is shown, but in this method I wanted that the viewBoard of my JContentPane is updated, but it isn't.
I tryied with:
jContentPane.revalidate()
and
jContentPane.repaint()
It only work if I put:
Java Code:viewBoard=null; jContentPane.add(getBoardGame(indexColPlayChip),BorderLayout.CENTER,1); jContentPane.revalidate();
more details: viewBoard is created in a new class that extends a JPanel, and it is added to my JContentPane in my JFrame.
-
Re: repaint() and revalidate() doesn't work in my JContentPane
I'm not sure if you've posted enough information to allow us to be able to answer your question.
- 11-20-2011, 06:30 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 27
- Rep Power
- 0
Re: repaint() and revalidate() doesn't work in my JContentPane
I have a model that extends observable and a view (in swing) that implements observer. When my model change, it call the update() method in my view. But it doesn't repaint it. I tried repaint() and revalidate(), but it doesn't work. If I put in the update() method the "new view" in a JDialog it show me the right new view. So I am sure it is correct. But when I put in the update() that it has to repaint it on the ContentPane, it doesn't work.
So my question why does it repaint itself right in a new JDialog, but not in the ContentPane?
-
Re: repaint() and revalidate() doesn't work in my JContentPane
Hopefully someone else will be able to help you, but I'm afraid that I don't have even a wild guess based on the information presented, other than that you've got a bug somewhere in code not shown.
Similar Threads
-
Repaint calling Statement Doesn't Work in my code ?
By nitin_daviet88 in forum CLDC and MIDPReplies: 2Last Post: 07-24-2010, 04:09 PM -
new JLabels not showing in JPanel (doing revalidate&repaint)
By r00tb33r in forum AWT / SwingReplies: 6Last Post: 06-16-2010, 07:03 AM -
repaint class doesnt work anymore... dunno why..
By Addez in forum New To JavaReplies: 9Last Post: 11-07-2009, 10:10 PM -
Why doesn't this work?
By Corder10 in forum New To JavaReplies: 1Last Post: 07-04-2009, 11:33 PM -
mouse click do not work after repaint
By nobody in forum Java 2DReplies: 8Last Post: 12-07-2008, 05:43 PM
Bookmarks