• Post Reply Bookmark Topic Watch Topic
  • New Topic

LList repaint not working  RSS feed

 
deep pat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I'm having big trouble repainting a JList after an element is inserted. So any help is mery much appreciated.

I've a JDialog,let's say ElementListWindow with a JList, let's say ElementList , along with other components such as JComboBox, JtextArea etc. At the start up, the ElementList is populated throught "DefaultListModel" by fetching the data form database via the object ListElementDAO. Next to the ElementList i've a button which opens a modal window (also a JDialog) so that the user can add an element to the JList. The new element is inserted to the base via ListElementDAO and what i'm tryin to do is that the change is reflected to the ElementList as well. So i'm using the pattern Observer/Observable so that the ListElementDAO, which extends Observable, notifies the ElementListWindow which implements Overver and it's method "update".

So when i insert a new element, the method "update" receives the new element. I put it in the DefaultListModel. Everything is fine until here. and try to repaint the ElementList butnothing seems to happen. The new item is not in the ElementList .


I've printed some of the properties of ElementList .

jListF.isValid() :true
jListF.isVisible():true
jListF.getParent()javax.swing.JViewport[,1,1,221x70,layout=javax.swing.ViewportLayout,alignmentX=0.0,alignmentY=0.0,
border=,flags=25165832,maximumSize=,minimumSize=,preferredSize=,isViewSizeSet=true,
lastPaintPosition=java.awt.Point[x=0,y=0],scrollUnderway=false]
jListF.getPeer() instanceof LightweightPeer =true


i've also tried

and also

but nothing works.

Is this because the widow that insert a new element is modal? Or is it because i'm trying to repaint in "update" method?

I don't understand where is the problem. Please help. I'm trying to solve it for several days.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deep, have you cross-posted this same question in another forum? It looks quite familiar to me for some reason? If so, have you read the FAQs about posting questions here before posting, specifically the one on cross-posting?

Much luck.
 
deep pat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes indeed. but the problem is solved . sorry!!
 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote: . . . have you read the FAQs . . . on cross-posting?

Much luck.
Thank you for noticing. This is the FAQ in question.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!