Go to Post ChiefDelphi is talking about women's clothing. What a time to be alive. - Karibou [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 01-10-2013, 08:46 PM
timothyb89 timothyb89 is offline
code monkey
FRC #1977 (Loveland High Robotics)
Team Role: Alumni
 
Join Date: Oct 2008
Rookie Year: 2009
Location: Loveland, Colorado
Posts: 45
timothyb89 will become famous soon enough
Re: Can I create a looping SmartdashBoard widget

If memory serves, the SmartDashboard widgets are just Swing components. The constructor would be executed once during initialization, and then the drawing methods (paint, paintComponent, etc) are run periodically as determined by Swing and the OS. Doing any kind of looping or long-executing tasks in these places would cause significant slowness in the UI, unfortunately.

If you want something to update continuously you're best off doing it from a background thread. The official camera widget does this to fetch new images: [source]
(Note that this code is a snapshot from the smartdashboard svn as of last year, but I doubt all that much has changed since then. Also know that this code does some bad things like calling System.gc() which is a pretty terrible idea)

The images are fetched in the background and then a call to repaint() is queued in the UI thread with SwingUtils.invokeLater(). The repaint() method will then be called "later" which then displays the fetched image and in theory should never cause any noticeable lag in the UI.
__________________
FRC-DB: A detailed, web-based scouting database for FRC teams with lots of interesting statistics.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:46 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi