package com.nigorojr.typebest;

import java.awt.Color;
import java.util.ArrayList;

import javax.swing.JLabel;

public class Word {
    private ArrayList<Letter> word = new ArrayList<Letter>();
    private String rawWord;

    /**
     * Accepts a String which is what will be shown in this JLabel.
     * The constructor will then split the word into letters and create a Letter
     * object for each letter.
     * 
     * @param word
     *            The word that will be shown as a collection of "Letter" class.
     */
    public Word(String word) {
        rawWord = word;

        split();
    }

    /**
     * Splits up the word into letters and add them to an ArrayList.
     */
    private void split() {
        for (int i = 0; i < rawWord.length(); i++) {
            Letter letter = new Letter(rawWord.charAt(i));
            word.add(letter);
        }
    }

    /**
     * Returns the width of the word by adding the width of all the letters
     * consisting the word.
     * 
     * @return The width of the word.
     */
    public int getWidth() {
        int width = 0;
        for (int i = 0; i < word.size(); i++)
            width += word.get(i).getWidth();
        return width;
    }
}

@@ -29,31 +29,8 @@
 t;%0A%0A
-import java.awt.Color;%0A
 impo
@@ -74,19 +74,19 @@
 .swing.J
-Lab
+Pan
 el;%0A%0Apub
@@ -100,16 +100,31 @@
 ss Word 
+extends JPanel 
 %7B%0A    pr
@@ -281,11 +281,11 @@
 is J
-Lab
+Pan
 el.%0A
@@ -395,16 +395,80 @@
  letter.
+ After that, Letter objects are added to the%0A     * this JPanel.
 %0A     * 
@@ -645,24 +645,115 @@
    split();%0A
+        for (int i = 0; i %3C this.word.size(); i++)%0A            this.add(this.word.get(i));%0A
     %7D%0A%0A    /
@@ -1020,344 +1020,7 @@
    %7D
-%0A%0A    /**%0A     * Returns the width of the word by adding the width of all the letters%0A     * consisting the word.%0A     * %0A     * @return The width of the word.%0A     */%0A    public int getWidth() %7B%0A        int width = 0;%0A        for (int i = 0; i %3C word.size(); i++)%0A            width += word.get(i).getWidth();%0A        return width;%0A    %7D
 %0A%7D%0A

Change Word class to extend JPanel