Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Repainting jPanel in Applet  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jApplet that contacts a web service every minute to update the content that it displays on a jPanel. When I run the applet in my NetBeans IDE it works fine, I have a countdown timer that shows when the panel will be updated and it updates at the correct time. But when I publish this applet as a Web Start or embed it as an applet, the repainting does not work. The countdown timer still works but the content of the jPanel is never updated. What is going on? Thanks

 
author and iconoclast
Posts: 24203
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the applet version manages to get the updated data? Applets have restrictions on the kind of network connections they can create; in general, an unsigned applet can only talk to the server it was downloaded from.
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it connects to the service initially to get data and populate the jPanel. But it never connects again, so it never updates the jPanel. I would think that if it was able to connect the first time then being able to connect to the web service would not be the problem. I was thinking that is was some problem with actually repainting the jPanel. Do you think differently?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like my first guess was wrong. Are you looking at the "Java Console" to see if you're getting any stack traces?
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea, Ive been watching the Console. I put in several system.out.println to follow the execution of everything and the Java Console from the Applet is the same as that from my NetBeans IDE. And there are no error messages. Its just not repainting as far as I can tell...
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. Weirdness. Well, how is the repainting supposed to be happening? Do you have a Swing "tree model", and is it being updated in such a way that it fires change events to the view?
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The timer counts down and when it reaches 0 it prompts a panel.repaint(). The panel has many rectangles on it that are filled with different colors. The server call updates an array that tells the jpanel what color to paint each component. Do you want the code?
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, when I refresh the page the data stays the same. If I launch the applet again in a new tab then the data is correct but never updates after the initial load, same as before. This is really puzzling..I can see everything working in the background but nothing gets updated on the screen.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!