Class MemoryMonitor

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class MemoryMonitor extends JComponent
Component which displays JVM memory usage. Clicking on it will call System.gc().
Since:
22 Dec 2009
Author:
Mark Taylor
See Also:
  • Constructor Details

    • MemoryMonitor

      public MemoryMonitor()
      Constructor.
  • Method Details

    • getTimer

      public Timer getTimer()
      Returns the timer which performs regular repaints of this component.
      Returns:
      timer
    • setVertical

      public void setVertical(boolean vertical)
      Sets the orientation for this component.
      Parameters:
      vertical - true for vertical movement of bars
    • getVertical

      public boolean getVertical()
      Returns the orientation of this component.
      Returns:
      true for vertical movement of bars
    • setReverse

      public void setReverse(boolean reverse)
      Sets bar movement to the opposite sense.
      Parameters:
      reverse - true to set the zero level to the non-default end
    • getReverse

      public boolean getReverse()
      Returns whether bar movement is in the opposite sense.
      Returns:
      true if the zero level is at the non-default end
    • setShowText

      public void setShowText(boolean showText)
      Sets whether the text should be displayed.
      Parameters:
      showText - true to display the result of getText()
    • getShowText

      public boolean getShowText()
      Returns whether text is being displayed.
      Returns:
      true if the result of getText() is being displayed
    • setColors

      public void setColors(Color maxColor, Color totalColor, Color usedColor)
      Set the colour scheme.
      Parameters:
      maxColor - colour for max memory bar
      totalColor - colour for total memory bar
      usedColor - colour for used memory bar
    • getColors

      public Color[] getColors()
      Returns the colour scheme.
      Returns:
      3-element array of colours: max memory, total memory and used memory
    • paintComponent

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

      public String getText()
      Returns the text which is painted onto this component. It's some indication of used and available memory, but can be overridden.
      Returns:
      text