//==================================================================================================
// G r a p h i c                                                                               Java
// S t r i n g I n d i c a t o r
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module provides a class to create an indicator component that displays a string value. */

// Package //---------------------------------------------------------------------------------------
package bpp.graphic;

// Importation //-----------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;

// S t r i n g I n d i c a t o r  Class //----------------------------------------------------------
/*CLASS StringIndicator */
/* Represents a component that displays a string value. */
public class StringIndicator extends Panel {
 //---------------------------------------------------------------------------------------Attributes
 protected TextField atLabel; // Component displaying the string value.
 protected Label     atTitle; // Component displaying the title.
 protected String    atValue; // Value to be displayed.
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD StringIndicator */ /* Builds an indicator for a given value. */
 public StringIndicator(String agValue) {
  super();

  atValue=agValue;
  setLayout(new BorderLayout(0,0));
  atLabel=new TextField(valueString(),15);
  atLabel.setEditable(false);
  add(atLabel,BorderLayout.CENTER);
 }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD StringIndicator */ /* Builds an indicator with a title for a given value. */
 public StringIndicator(String agValue,String agTitle) {
  super();

  atValue=agValue;
  setLayout(new BorderLayout(0,0));
  atLabel=new TextField(valueString(),15);
  atLabel.setEditable(false);
  atTitle=new Label(agTitle,Label.CENTER);
  add(atTitle,BorderLayout.NORTH);
  add(atLabel,BorderLayout.CENTER);
 }
 //--------------------------------------------------------------------------------------------Value
 /*METHOD StringIndicator */ /* Returns the value of the indicator. */
 public String value() { return (atValue); }
 //-----------------------------------------------------------------------------------------SetValue
 /*METHOD StringIndicator */ /* Sets the value of the indicator. */
 public void setValue(String agValue) {
  atValue=agValue;
  atLabel.setText(valueString());
 }
 //--------------------------------------------------------------------------------------ValueString
 protected String valueString() { return (value()); }
}

// End //-------------------------------------------------------------------------------------------