StatusBarPanel.java :  » Development » Houston » houston » swing » Java Open Source

Java Open Source » Development » Houston 
Houston » houston » swing » StatusBarPanel.java
/*
** Houston - Status and Logging Toolkit
** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
**
** This program is free software.
**
** You may redistribute it and/or modify it under the terms of the GNU
** Lesser General Public License as published by the Free Software Foundation.
** Version 2.1 of the license should be included with this distribution in
** the file LICENSE, as well as License.html. If the license is not
** included with this distribution, you may find a copy at the FSF web
** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
**
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
** REDISTRIBUTION OF THIS SOFTWARE.
**
*/

package houston.swing;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import houston.*;

public class StatusBarPanel extends JPanel implements StatusListener
{
   private JLabel _left;

   public StatusBarPanel()
   {
      setBorder( BorderFactory.createLoweredBevelBorder() );
      _left = new JLabel( " " );

      setLayout( new BorderLayout() );
      add( _left, BorderLayout.CENTER );

      print( "Welcome " + System.getProperty( "user.name" ) );

      Status.addListener( this );
   }

   public void clear()
   {
      _left.setText( " " );
   }

   public void error( String msg )
   {
      printError( msg );
   }

   public void fatal( String msg )
   {
      printError( msg );
   }

   public void hint( String msg )
   {
      print( msg );
   }

   public void info( String msg )
   {
      print( msg );
   }

   public void info( int level, String msg )
   {
      print( msg );
   }

   public void warning( String msg )
   {
      printWarning( msg );
   }

   private void print( String msg )
   {
      _left.setForeground( Color.black );
      _left.setText( msg );
   }

   private void printError( String msg )
   {
      _left.setForeground( Color.red );
      _left.setText( msg );
   }

   private void printWarning( String msg )
   {
      _left.setForeground( Color.orange );
      _left.setText( msg );
   }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.