public ColorPallet(ColorPalletState initColorPalletState)
    {
        // WE'LL KEEP THE STATE, SINCE WE'LL USE
        // IT EVERY TIME WE REFRESH
        state = initColorPalletState;
        
        XMLUtilities xmlloader = new XMLUtilities();
        Document palletSettings = null;
        try {
            palletSettings = xmlloader.loadXMLDocument(PoseurSettings.COLOR_PALLET_SETTINGS_XML, PoseurSettings.COLOR_PALLET_SETTINGS_SCHEMA);
        } catch(InvalidXMLFileFormatException ixffe)
        {
            JOptionPane.showMessageDialog(this, ixffe.toString());
            System.exit(0);
        }
        
        Node root = palletSettings.getFirstChild();
        NodeList children = root.getChildNodes();
        int numColorsInPallet = xmlloader.getIntData(palletSettings, PoseurSettings.PALLET_SIZE_NODE);
        int numRows = xmlloader.getIntData(palletSettings, PoseurSettings.PALLET_ROWS_NODE);
        int numFixedColors;
        int red, green, blue;
        Color[] palletColors = new Color[numColorsInPallet];
        Node currentNode = root;
        int x=0;
        while (true)
        {
            if ((currentNode = xmlloader.getNodeInSequence(palletSettings, PoseurSettings.PALLET_COLOR_NODE, x))==null)
            {
                break;
            }
            Node colorNode = currentNode.getFirstChild();
            red = Integer.parseInt(colorNode.getTextContent());
            colorNode = colorNode.getNextSibling();
            green = Integer.parseInt(colorNode.getTextContent());
            colorNode = colorNode.getNextSibling();
            blue = Integer.parseInt(colorNode.getTextContent());
            palletColors[x]=new Color (red,green,blue);
            x++;
        }
        
        numFixedColors = x;
        Color defaultColor = PoseurSettings.UNASSIGNED_COLOR_PALLET_COLOR;
        Node defaultColorNode; 
        if ((defaultColorNode = xmlloader.getChildNodeWithName(palletSettings, PoseurSettings.DEFAULT_COLOR_NODE))!=null)
        {
            red = Integer.parseInt(defaultColorNode.getChildNodes().item(0).getTextContent());
            green = Integer.parseInt(defaultColorNode.getChildNodes().item(1).getTextContent());
            blue = Integer.parseInt(defaultColorNode.getChildNodes().item(2).getTextContent());
            defaultColor = new Color(red, green, blue);
        } 
        
        state.loadColorPalletState(palletColors, numRows, numFixedColors, defaultColor);
        
        
        colorPalletButtons = new JButton[numColorsInPallet];
        
        
        for (int i = 0; i < numColorsInPallet; i++)
        {
            // CONSTRUCT AND ADD EACH BUTTON ONE AT A TIME
            colorPalletButtons[i] = new JButton();
        }
        
        // AND NOW ARRANGE THEM INSIDE THIS PALLET
        int colorPalletRows = state.getColorPalletRows();
        int colorPalletSize = colorPalletButtons.length;
        GridLayout gL = new GridLayout(colorPalletRows, colorPalletSize/colorPalletRows);
        this.setLayout(gL);
        Border etchedBorder = BorderFactory.createEtchedBorder();
        this.setBorder(etchedBorder);
        
        // NOW PUT THE BUTTONS INTO THE COLOR PALLET PANEL
        // WITH THEIR PROPER INITIAL COLORS
        int row = 0;
        int col = 0;
        for (int i = 0; i < colorPalletSize; i++)
        {
            if (col == (colorPalletRows/colorPalletRows))
            {
                col = 0;
                row++;
            }
            this.add(colorPalletButtons[i]);
            colorPalletButtons[i].setBackground(state.getColorPalletColor(i));
        }
    }