View Javadoc

    1   /*
    2    * @(#) ContextFrame.java Oct 26, 2003
    3    *
    4    * Copyright (c) 2002-2005 Delft University of Technology Jaffalaan 5, 2628 BX
    5    * Delft, the Netherlands. All rights reserved.
    6    *
    7    * This software is proprietary information of Delft University of Technology
    8    * The code is published under the Lesser General Public License
    9    */
    10  package nl.tudelft.simulation.dsol.gui.windows;
    11
    12  import java.awt.Dimension;
    13
    14  import javax.naming.NamingException;
    15  import javax.naming.event.EventContext;
    16  import javax.swing.JFrame;
    17  import javax.swing.JScrollPane;
    18  import javax.swing.JTree;
    19  import javax.swing.WindowConstants;
    20
    21  import nl.tudelft.simulation.logger.Logger;
    22  import nl.tudelft.simulation.naming.context.ContextTreeModel;
    23
    24  /***
    25   * The ContextFrame <br>
    26   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
    27   * University of Technology </a>, the Netherlands. <br>
    28   * See for project information <a
    29   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
    30   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
    31   * General Public License (LGPL) </a>, no warranty.
    32   *
    33   * @version $Revision$ $Date$
    34   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja">Peter Jacobs </a>
    35   */
    36  public class ContextFrame extends JFrame
    37  {
    38  	/*** the context */
    39  	private EventContext context = null;
    40
    41  	/***
    42  	 * constructs a new ContextFrame
    43  	 *
    44  	 * @param context the context to see
    45  	 */
    46  	public ContextFrame(final EventContext context)
    47  	{
    48  		super("ContextUtil: " + context);
    49  		this.context = context;
    50  		try
    51  		{
    52  			this.initialize();
    53  		} catch (NamingException namingException)
    54  		{
    55  			Logger.warning(this, "ContextFrame", namingException);
    56  		}
    57  		this.pack();
    58  		this.setVisible(true);
    59  		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    60  	}
    61
    62  	/***
    63  	 * initializes the contextframe
    64  	 *
    65  	 * @throws NamingException on failure
    66  	 */
    67  	private void initialize() throws NamingException
    68  	{
    69  		this.setContentPane(new JScrollPane(new JTree(new ContextTreeModel(
    70  				this.context, null, true))));
    71  		((JScrollPane) this.getContentPane()).setPreferredSize(new Dimension(
    72  				500, 500));
    73  	}
    74  }