/* * StatusPanel.java * * Copyright (c) 2003-2004 Digi International * This program and the information contained in it is confidential and * proprietary to Digi International and may not be used, copied, or re- * produced without the prior written permission of Digi International. * */ package com.digi.config.ui; import com.digi.config.core.*; import com.digi.config.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; /** * This class is a panel that shows status information for the application. * It contains a text area for status messages as well as a tray area in which * UI components (such as images, buttons, etc.) can be added. * This is currently implemented as a singleton. */ public class StatusPanel extends JPanel { private static StatusPanel singletonSelf = null; // Singleton instance private JLabel statusLine; private JPanel trayPanel; /** * Get the status panel. * @return the singleton instance of the status panel. */ public static StatusPanel getInstance() { if (singletonSelf == null) { singletonSelf = new StatusPanel(); } return singletonSelf; } /** * Set the status text in the message area. * @param msg the message text. */ public void setStatusText(String msg) { if (msg != null) { statusLine.setText(msg); statusLine.paintImmediately(statusLine.getVisibleRect()); } } /** * Get the status text in the message area. * @return the message text. */ public String getStatusText() { return statusLine.getText(); } /** * Add a component to the tray area. * @param comp the UI component to add to the tray. */ public void addTrayComponent(Component comp) { if (comp != null) { trayPanel.add(comp); statusLine.paintImmediately(statusLine.getVisibleRect()); } } /** * ctor - private to enforce singleton. */ private StatusPanel() { setLayout(new BorderLayout()); statusLine = new JLabel(ConfigResource.getUiRbString("ReadyStatus")); trayPanel = new JPanel(); add(statusLine, BorderLayout.CENTER); add(trayPanel, BorderLayout.EAST); } }