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) {
  Dimension d = size(); 
  // Write title:
  g.setFont(new Font("Helvetica", Font.BOLD, 12));
  FontMetrics f = g.getFontMetrics();                   
  int height = f.getHeight();                           
  int descent = f.getDescent();                         
  int stringWidth = f.stringWidth(title);               
  int xOrigin = (d.width - stringWidth) / 2;            
  int yOrigin = d.height * 3 / 4;                       
  g.drawString(title, xOrigin, yOrigin);                
 }
 public Dimension minimumSize() {return new Dimension(150, 100);} 
 public Dimension preferredSize() {return new Dimension(150, 100);} 
}
