001/*
002
003$Header: v:/cvsroot/open/projects/WebARTS/ca/bc/webarts/widgets/StatusBar.java,v 1.1.1.1 2001/03/03 23:36:07 tgutwin Exp $
004
005$Log: StatusBar.java,v $
006Revision 1.1.1.1  2001/03/03 23:36:07  tgutwin
007Imported Sources
008
009//  
010//    This is a status bar for the bottom of an internal desktop window.
011//  
012//  Revision 1.1  by: Tom Gutwin  Rev date: Wed May 03 15:23:12 2000
013//    Added QVCS Keywords as well as addeded it to the webarts widgets
014//    package
015//  
016//  Revision 1.0  by: Tom Gutwin  Rev date: Tue Apr 04 13:03:12 2000
017//    Initial revision.
018//  
019//  $Endlog$
020
021*/
022
023
024package ca.bc.webarts.widgets;
025
026/*  This program requires JVM 1.2 or JVM 1.1.5 with the Swing 1.02(or higher) components       */
027/*  If building with the OS/2 JDK you must have at least 1.1.4 with the 1.1.4 fixes */
028import java.awt.*;
029
030// with swing 1.0 use 
031//import com.sun.java.swing.*;
032// with JDK 1.2 or swing 1.1use 
033import javax.swing.*;
034
035
036/*************************************/                                                                   
037/*   The StatusBar Panel             */                                                                   
038/*************************************/                                                                   
039public class StatusBar extends JPanel                                                                   
040{
041        private JInternalFrame currentFileFrame;
042        private JLabel[] label;
043        private int numberOfStatusMessages,i;
044        private GridBagLayout layout = new GridBagLayout();
045        private GridBagConstraints c = new GridBagConstraints();
046        private Font defaultFont = new Font("Arial",Font.BOLD,12);
047        private Font currentFont;
048
049public StatusBar(int numLabels,double[] sizes,String[] message)
050        {
051                numberOfStatusMessages = numLabels;
052                label=new JLabel[numberOfStatusMessages];
053
054                /* set up the statusbar layout */
055                /*******************************/
056                c.fill = GridBagConstraints.HORIZONTAL; 
057                setLayout(layout);
058                setBorder(BorderFactory.createRaisedBevelBorder());
059                getInsets(new Insets(2,5,2,5));
060
061                /*****************************/
062                /* create the labels         */
063                /*****************************/
064                for (i=0;i<numberOfStatusMessages;i++)
065                {
066                        label[i] = new JLabel(message[i]);  
067                        currentFont = defaultFont;
068                        label[i].setFont(currentFont);
069//                      label[i].setMinimumSize(new Dimension(sizes[i],20));
070
071                        /* set up the gridbaglayout constraints for this message */
072                        /*********************************************************/
073                        if(((i+1) == numberOfStatusMessages) )     // LAST MESSAGE in ROW
074                                c.gridwidth = GridBagConstraints.REMAINDER;
075                        else
076                                if(((i+2) == numberOfStatusMessages) )     // 2nd LAST MESSAGE in ROW
077                                        c.gridwidth = GridBagConstraints.RELATIVE;
078
079                        /* set up the cell sizing  */
080                        /***************************/
081                        c.weightx = sizes[i] * 10 ;
082                        layout.setConstraints(label[i], c);
083                        add(label[i]);
084                }
085        }
086        
087public void     setMessageText(int i, String message)
088        {
089        label[i].setText(message);
090    }
091
092public void     setMessageIcon(int i, ImageIcon icon)
093        {
094        label[i].setIcon((Icon)icon);
095    }
096
097public void             updateFont(int msgNum, Font f)
098        {
099                label[msgNum].setFont(f);
100        }
101        
102public void             updateBackgroundColour(int msgNum, Color c)
103        {
104                label[msgNum].setBackground(c);
105        }
106}
107
108
109
110