private void calculateSizes(){
  this.prefferedSize=new Dimension();
  final BufferedImage image=new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d=image.createGraphics();
  g2d.setFont(font);
  final FontMetrics metrics=g2d.getFontMetrics();
  this.lineHeight=metrics.getHeight();
  this.prefferedSize.height=this.lineHeight * 8;
  for (  String s : text) {
    prefferedSize.width=Math.max(prefferedSize.width,metrics.stringWidth(s));
  }
  this.prefferedSize.width=prefferedSize.width + 6 * metrics.stringWidth(" ");
}

private void calculateSizes ( ) { this . prefferedSize = new Dimension ( ) ; final BufferedImage image = new BufferedImage ( 100 , 100 , BufferedImage . TYPE_INT_RGB ) ; final Graphics2D g2d = image . createGraphics ( ) ; g2d . setFont ( font ) ; final FontMetrics metrics = g2d . getFontMetrics ( ) ; this . lineHeight = metrics . getHeight ( ) ; this . prefferedSize . height = this . lineHeight * 8 ; for ( String s : text ) { prefferedSize . width = Math . max ( prefferedSize . width , metrics . stringWidth ( s ) ) ; } this . prefferedSize . width = prefferedSize . width + 6 * metrics . stringWidth ( " " ) ; }
calculates the line height and preferred size of this component depending on the given font .
