SortAnimationPanel - setBackground(Color.white); } public...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Author: Lewis and Loftus // // Solution to Programming Project 6.14 // //******************************************************************** / import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.util.Random; i public class SortAnimationPanel extends JPanel { private Timer timer; private SteppedSort sortEngine; private final int DELAY = 200, NUM = 50, MAX = 85; public SortAnimationPanel() { int[] numbers = new int[NUM]; Random gen = new Random(); for (int i=0; i<NUM; i++) numbers[i] = gen.nextInt(MAX) + 16; sortEngine = new SteppedSort(numbers); timer = new Timer(DELAY, null); timer.addActionListener(new ReboundListener()); timer.start();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: setBackground(Color.white); } public void paintComponent(Graphics page) { super.paintComponent(page); sortEngine.draw(page, getWidth(), getHeight()); } //***************************************************************** // Represents the action listener for the timer. //***************************************************************** private class ReboundListener implements ActionListener { //--------------------------------------------------------------// Performs one step in the sort and updates the display //--------------------------------------------------------------public void actionPerformed (ActionEvent event) { if (!sortEngine.sortFinished()) { sortEngine.nextStep(); repaint(); } } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 2

SortAnimationPanel - setBackground(Color.white); } public...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online