位置、大小和对齐

Java Swing. 基础篇,这本书的p.68有一段的程式码:
Rectangle r = new Rectangle( );
r = frame.getBounds(r);
System.out.println("X = " + r.x());
System.out.println("Y = " + r.y());
System.out.println("Width = " + r.width());
System.out.println("Height = " + r.height());

这一段是错的,我用java 1.6的去编译,发现找不到方法,查了手册:
http://java.sun.com/javase/6/docs/api/java/awt/Rectangle.html.
The Rectangle class has the fields:
Field Summary
int height
The height of the Rectangle.
int width
The width of the Rectangle.
int x
The X coordinate of the upper-left corner of the Rectangle.
int y
The Y coordinate of the upper-left corner of the Rectangle.
我想这是属性不是方法吧,改成这样:
Rectangle r = new Rectangle( );
r = frame.getBounds(r);
System.out.println("X = " + r.x);
System.out.println("Y = " + r.y);
System.out.println("Width = " + r.width);
System.out.println("Height = " + r.height);

之后再编译,就对了!