import java.awt.*;
public class MeterCanvas extends Canvas {
 String title = "Title to be Supplied";
 int minValue = 0, maxValue = 30, value = 15;
 public void paint(Graphics g) {
  // Obtain current Color instance:
  Color colorHandle = g.getColor();     
  // Reset color temporarily:
  g.setColor(Color.blue);               
  // Obtain Dimension instance and draw
  Dimension d = getSize(); 
  int meterWidth = d.width * 3 / 4;
  int dialPosition
    = meterWidth * (value - minValue) / (maxValue - minValue);
  int xOrigin = (d.width - meterWidth) / 2; 
  int yOrigin = d.height / 2;
  g.drawLine(xOrigin, yOrigin, xOrigin + meterWidth, yOrigin);
  g.drawLine(xOrigin + dialPosition, yOrigin,
             xOrigin + dialPosition, yOrigin - 10);
  // Restore color:
  g.setColor(colorHandle);              
 }
 public Dimension getMinimumSize() {return new Dimension(150, 100);} 
 public Dimension getPreferredSize() {return new Dimension(150, 100);}
}
