summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Zentriert.inc
blob: aa27d8513841571f5ed20d0e1f8ca1fd76f34483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* Zentriert.inc */

public void paint(Graphics g)
{
  int maxX=getSize().width-getInsets().left-getInsets().right;
  int maxY=getSize().height-getInsets().top-getInsets().bottom;
  String s="Die Client-Area ist "+maxX+"*"+maxY+" Pixel gro�";
  FontMetrics fm = g.getFontMetrics();
  int slen = fm.stringWidth(s);
  g.drawString(
    s,
    getInsets().left + ((maxX - slen)/2),
    getInsets().top  + (maxY/2)
  );
}