import javax.swing.JFrame;
import java.util.ArrayList;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
/**
* Describe class CollectionDisplay here.
*
*
* Created: Mon Apr 11 16:44:41 2011
*
* @author Dr. John F. Santore
* @version 1.0
*/
public class CollectionDisplay extends JFrame {
private ArrayList myList;
public int ELEMENT_SIZE = 100;
public int Y_POS = 75;
public int BOX_H = 50;
public int BOX_W = ELEMENT_SIZE;
public CollectionDisplay() {
super("CS1 Collection Displayer");
setSize(400, 200); //wide and short. Magic number are bad I know.
setVisible(true);
}
public void displayCollection(ArrayList l){
myList = l;
setSize(100+myList.size()*ELEMENT_SIZE, 200);
repaint();
}
public void paint(Graphics g){
Color oldColor = g.getColor();
super.paint(g);
//error checking, only paint of there is something to paint
if(myList == null)
return;
for (int i = 0; i