Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing, JApplet, and why do I need to resize the window for updates to show?

 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I've run into something of a stumbling block, no doubt due to the fact that I haven't used Swing in a while.

Anyway, I'm actually writing a small applet program, although I've also included a "main" so I can test it from the command line without a browser. Behavior both from within the browser and stand-alone are the same.

The basic premise is that I have a Border layout screen, with the PAGE_START section having a JPanel which contains a JLabel, the CENTER section has a JPanel with JLabels that get added, then the PAGE_END has two buttons, one of which is currently nonfunctional, and the other which is used to add items to the JPanel in the center section.


Program sequence is as follows:

1) Start by initializing variables, and set up the GUI
2) Fill in the items in the middle from a file
3) If the user clicks "Add", get info from the user with a JOption Pane
4) Append the new item to an existing file
5) Add the new item to the item list

Everything works except for step 5. When I add the new item to the list, it won't show unless I resize the window (or in the JApplet form, resize the browser window).

Does anyone know why this is? Is there an extra step I need to take to cause the newly added item to show up immediately without the need for resizing?

Here's the code, in a bit of rough form:


[ September 07, 2006: Message edited by: Joe Vahabzadeh ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this first

 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, that did the trick. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic