• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Applet UI/Animation problems

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a thorny problem someone here may be able to help me with:

I have a package "Nomad", with various classes, but driven from an Applet - "Tracker". Part of my package is a subclass of Canvas ("MapDisplay") which I use to display a map of the world. Given a list of cities into Tracker, it uses the MapDisplay component to scroll from city to city (the map is bigger than the MapDisplay area), in order, and draw a red line between each one (like on the Indiana Jones movies).

All this works fine, but what I'd like to do is have a group of buttons at the bottom of the applet to control direction of travel along the route, pausing it so that comments can be read, etc. My problem is that when I add these buttons, it doesn't register any clicks until after the map has finished scrolling to its last city (which is a bit late).

Now some structure info:
-My components are created as part of a separate Thread within init(), which is also where the city list is loaded.
-My scrolling code is in paint(), and basically gets a ListIterator and steps through the list of cities and scrolls from one to the next.

I can't help but think my code needs to be moved around a bit. This is my first applet since "Hello World", so I'm not sure of the structure of what functions kick off when, and which are in separate Threads etc.
I tried moving my scrolling code into start(), but that ended up taking longer to load, before just showing the map at the last city, red line already drawn.

What I need is the map to start scrolling as it does at the moment, but to register a button click immediately and perform the appropriate action. If no buttons are pressed, it just runs to the end and stops.

Any ideas? I'm sort of lost here.

Thanks in advance,

BTW, I'm using JDK1.5.0
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic