View Javadoc
1   package nl.tudelft.simulation.dsol.swing.gui;
2   
3   import javax.swing.JPanel;
4   import javax.swing.border.TitledBorder;
5   
6   /**
7    * JPanel with an outline and a name. Code based on OpenTrafficSim project component with the same purpose.
8    * <p>
9    * Copyright (c) 2020-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
10   * for project information <a href="https://simulation.tudelft.nl/dsol/manual/" target="_blank">DSOL Manual</a>. The DSOL
11   * project is distributed under a three-clause BSD-style license, which can be found at
12   * <a href="https://https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">DSOL License</a>.
13   * </p>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   */
17  public class LabeledPanel extends JPanel
18  {
19      /** */
20      private static final long serialVersionUID = 20141222L;
21  
22      /**
23       * Create a JPanel with border and caption.
24       * @param caption String; the caption of the LabeledPanel
25       */
26      public LabeledPanel(final String caption)
27      {
28          setBorder(new TitledBorder(null, caption, TitledBorder.LEADING, TitledBorder.TOP, null, null));
29      }
30  
31      /** {@inheritDoc} */
32      @Override
33      public String toString()
34      {
35          return "LabeledPanel [caption=" + ((TitledBorder) getBorder()).getTitle() + "]";
36      }
37  }