Graphics2D.getDeviceConfiguration()的奇怪行为

时间:2014-08-27 12:27:40

标签: java

这是我的程序草图,以说明问题:

view = getGraphicsConfiguration().createCompatibleImage(100, 100);

// creating a BufferedImage with size 100x100

Rectangle r = view.createGraphics().getDeviceConfiguration().getBounds();

// this correctly returns a rectangle of 100x100, as in my understanding the device
// is the BufferedImage and its size is 100x100

/* Later a new object is created, where 'view' again is assigned, so it is a different instance variable (even if it were the same object, I would not understand the behavior). */

view = getGraphicsConfiguration().createCompatibleImage(200, 200);

// creating a BufferedImage with size 200x200

Rectangle r = view.createGraphics().getDeviceConfiguration().getBounds();

// now this again returns a rectangle of 100x100, though I would expect it to return
// 200x200 (!?), for some reason the system seems to remember the old settings?

我检查了上面GraphicsConfiguration的两次调用返回的getDeviceConfiguration()。这是同一个对象。

感谢您的任何评论!

0 个答案:

没有答案