/** This class is responsible for storing and displaying the game history * @author Kristof Friedrichsen * @author Ryan Mann * @author Bob Free * @author Pat O'Neill * @version December 15, 2006 **/ package chutesladder; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class GameHistory extends JPanel { static public JTextArea gameHistory; JScrollPane paneGH; public GameHistory() { //setSize(200,200); setLayout(new BorderLayout()); gameHistory = new JTextArea("Welcome to Chutes and Ladders", 17, 22); gameHistory.setWrapStyleWord(true); gameHistory.setEditable(false); paneGH = new JScrollPane(gameHistory); paneGH.setPreferredSize(new Dimension(200,300)); paneGH.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneGH.setViewportView(gameHistory); add(BorderLayout.NORTH, paneGH); } static public void showMove(String Player, int show) { try { String show2 = "\n"+Player+" has spun a: "+show; gameHistory.append(show2); gameHistory.setCaretPosition( gameHistory.getDocument().getLength() ); } catch(NullPointerException npe){} } }