Class JStatusBar

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public final class JStatusBar extends JPanel
The JStatusBar class constructs a JPanel that provides an application with a status bar. The status bar contains an indicator of the battery level (Windows platforms only) as well as the current memory usage (they are automatically updated every 30 seconds).

Note that this class cannot be subclassed!

Version:
03/03/2021
Author:
Sven Maerivoet
See Also:
  • Field Details

    • kUpdatePeriod

      public static final int kUpdatePeriod
      The battery level and memory usage labels' update period in milliseconds.
      See Also:
    • kHeight

      public static final int kHeight
      The height of the status bar (expressed in pixels).
      See Also:
  • Constructor Details

    • JStatusBar

      public JStatusBar()
      Constructs a JStatusBar object.

      Note that the GUI resizable-icon is shown.

    • JStatusBar

      public JStatusBar(boolean showGUIResizable, ArrayList<JLabel> customLabels)
      Constructs a JStatusBar object and sets up optional custom labels that are shown to the right hand side.
      Parameters:
      showGUIResizable - indicates whether or not the resizable-icon should be shown
      customLabels - an ArrayList of custom labels, or null if none are provided
  • Method Details

    • setStatusText

      public void setStatusText(String statusText)
      Sets the status text.
      Parameters:
      statusText - the new status text to show
    • clearStatusText

      public void clearStatusText()
      Clears the status text.
    • setStatusTextColor

      public void setStatusTextColor(Color color)
      Sets the status text's color.
      Parameters:
      color - the status text's color
    • clearStatusTextColor

      public void clearStatusTextColor()
      Reverts the status text's color to black.
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • updateBatteryLevelAndMemoryUsage

      public void updateBatteryLevelAndMemoryUsage()
      Updates the battery level and memory usage labels.