Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign for a JApplet animation using Swing and Threads
    primarykey
    data
    text
    <p>I'm trying to implement a small Applet that does some animation. I would like to do the animation in a JPanel and below the Animation JPanel, have play/pause, and skip buttons to control the animation. To do this correctly, I think I need to have the animation in a Thread. (correct?)</p> <p>My Questions are: Whats is a good way to organize my Classes for this application? How to I get my animation thread to run inside a JPanel?</p> <p>I've been looking in the tutorials at oracle.com and this is what I have so far...</p> <pre><code>Class AnimationApplet extends JApplet { ... public void init(){ try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { createGUI(); } }); } catch (InterruptedException ex) { Logger.getLogger(TabApplet.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(TabApplet.class.getName()).log(Level.SEVERE, null, ex); } } } private void createGUI() { AnimationPanel ac = new AnimationPanel(); this.setConentPane(ac); } } // Class AnimationApplet class AnimationPanel extends JPanel implements ActionListener { ... } </code></pre> <p>Edit: I don't know if this will help, but here's exactly what I'm trying to do. I'm creating a guitar tab player so it would need to continue sliding the notes across the screen and then at certain points (16th notes), check if there are notes to animate. This seems kind of difficult because you can't divide ms by the beats per minute evenly. So for now, I'm thinking of dividing it into 4 or 5 speeds (slowest, slow, medium, etc);</p> <p>Thanks,</p> <p>Nate</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload