请教draw2d里面的一函数 translateToAbsolute(rect)请问 translateToAbsolute()这个函数有什么作用?用和不用没什么区别阿?比如: Rectangle rect = figure.getBounds().getCopy(); figure.translateToAbsolute(rect); text.setBounds(rect.x,rect.y,rect.width,rect.height); 我去掉后程序的运行结果还是没变啊? 回答: 就是转换相对位置到绝对位置 例如: figure在它父亲内的位置为50,50 figure的父亲是最外层,它的位置为100,100 那么转换后的位置就是150,150 你的程序之所以没有效果 text.setBounds(rect.x,rect.y,rect.width,rect.height); 执行这句text的位置是不会变的 应该是 text.getParent().setConstraint(text,rect); 转贴网址:http://www./bbs/read-cec-tid-6156-keyword-draw2d.html |
|