This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet UI/Animation problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet UI/Animation problems" Watch "Applet UI/Animation problems" New topic
Author

Applet UI/Animation problems

Jamie Burrell
Greenhorn

Joined: Oct 05, 2004
Posts: 3
Hi,

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,
J

BTW, I'm using JDK1.5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet UI/Animation problems
 
Similar Threads
How to implement a "data model"
compiling help
Override paintComponent
Applet using a graphical map
Iterating over a (kind of) linked list