/*
 * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */
package bingo.shared;

import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import java.net.*;
import java.io.*;
import java.util.Vector;

public class PlayerInfoPane extends JPanel implements PlayerListener {
    protected JScrollPane scrollPane;
    protected JTable cardsAndPlayers;
    protected PlayerInfoModel model;

    public PlayerInfoPane() {
	super(false); //XXX

	model = new PlayerInfoModel();
        cardsAndPlayers = new JTable(model);
	model.addTableModelListener(cardsAndPlayers);
	
        //Create the scroll pane and add the table to it. 
	//XXX why isn't this an instance method?
	scrollPane = JTable.createScrollPaneForTable(cardsAndPlayers);

	//Add the scroll pane to this panel.
	setLayout(new GridLayout(1, 0));
        add(scrollPane);

	scrollPane.setPreferredSize(new Dimension(300, 50)); //arbitrary 

        try {
            new PlayerListenerThread(this).start();
        } catch (java.io.IOException e) {
            //PENDING what to do?
        }
    }

    // Safe to call from any thread.
    public void updatePlayer(PlayerRecord playerRecord) {
	model.updatePlayer(playerRecord);
    }

    // Safe to call from any thread.
    public void clear() {
	model.clear();
    }
}
