import java.awt.*; import java.awt.event.*; import java.lang.Integer; import java.util.Calendar; import java.io.File; import javax.swing.*; import javax.swing.event.*; /** * MessagesPane - Displays the messages sent by the other participants. * * @author Paul Kronenwetter * @author Jayme Manning * *

* Paul Kronenwetter
* Jayme Manning
* Trade Secrets and/or Confidential
* Commercial or Financial Information
* Exempt From Disclosure Under the Freedom
* of Information Act (5 USC 552(b)(3)
* and 5 USC 552(b)(4)) and Under 18 USC 1905
*

*

* Proprietary Information Notice
* * This document contains information proprietary to, and is the * sole property of, Paul Kronenwetter and Jayme Manning. It shall not * be reproduced, used or disclosed in any manner or for any purpose * not authorized in writing by both Paul Kronenwetter and * Jayme Manning, and except, as retention may be so authorized, it * shall be returned to Paul Kronenwetter or Jayme Manning upon * request.

*

© 1998 by Paul Kronenwetter and Jayme * Manning
All Rights Reserved

* * @version * $Revision: 1.6 $
* $Date: 1998/12/17 17:13:09 $

* *

 * $Log: MessagesPane.java,v $
 * Revision 1.6  1998/12/17 17:13:09  cps606
 * Modified to deal with a cell render.
 *
 * Revision 1.5  1998/12/17 15:57:48  cps606
 * Changed from text area to list.
 *
 * Revision 1.4  1998/12/15 22:56:01  cps606
 * * Manually edited the comments to correct formatting.
 *
 * Revision 1.3  1998/12/15 00:07:58  cps606
 * * Cleaned up and added documentation.  Rearranged methods a little
 *   as seemed appropriate.
 *
 * Revision 1.2  1998/12/13 21:41:11  cps606
 * * Added getPreferredSize Method
 * * Removed Custom TextArea references.
 *
 * Revision 1.1  1998/12/12 03:22:11  kronenpj
 * * First CVS checkin.
 *
 * 
*/ public class MessagesPane extends JPanel { private final String rcsId="$Id: MessagesPane.java,v 1.6 1998/12/17 17:13:09 cps606 Exp $"; private int Rows,Columns; private Color bgColor=Color.white; private Color fgColor=Color.black; private JLabel paneLabel; private JList messagesArea; private JScrollPane scrollPane; // For the inner class's dealings... private Component draggedFrom, draggedTo; private JPanel northPanel, centerPanel; private DefaultListModel listModel; /** * Void constructor that calls realCtor. */ public MessagesPane() { realCtor(); } /** * Replies to requests for this component's preferred size. * * @return The preferred size of this panel in a Dimension. */ public Dimension getPreferredSize() { return new Dimension(500,250); } /** * Method to re-initialize panel. Probably not needed, except for * debugging purposes. */ public void reset() { init(); } // Start of private methods and classes. /** * This is the method that does the "real" work of setting up the * variables and other objects needed to make this panel work. */ private void realCtor() { // Make the colors "sane" setForeground(fgColor); setBackground(bgColor); // Make sure this panel uses a BorderLayout. setLayout(new BorderLayout()); // Set up the title bar... northPanel = new JPanel(); paneLabel = new JLabel("Messages"); northPanel.add(paneLabel); // Create the area for the actual messages... listModel = new DefaultListModel(); messagesArea = new JList(listModel); scrollPane = new JScrollPane(); messagesArea.setCellRenderer(new MessageCellRenderer(messagesArea)); scrollPane.add(messagesArea); scrollPane.getViewport().setView(messagesArea); scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // Add these elements to the layout. add(northPanel,BorderLayout.NORTH); add(scrollPane,BorderLayout.CENTER); } /** * addMessage - Method used to add a message to the List. * * @param message - JLabel containing message */ public void addMessage(JLabel message) { listModel.addElement(message); messagesArea.validate(); } /** * addMessage - Method used to add a message to the List. * * @param message - Message Panel. */ public void addMessage(JTextArea message) { String x = message.getText(); listModel.addElement(x); // messagesArea.validate(); } /** * addMessage - Method used to add a message to the List. * * @param message - Message string. */ public void addMessage(String message) { listModel.addElement(message); messagesArea.validate(); } /** * Initialization method for the CalendarPane. Also probably not * needed except for debugging. */ private void init() { validate(); } }