java 中 Rectangle 类 的setRect 和setBounds 有什么区别么?
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/07/30 00:08:33
java 中 Rectangle 类 的setRect 和setBounds 有什么区别么?
试了一下效果一样 那不是多此一举 setRect底层多了这些看不懂
int newx,newy,neww,newh;
if (x > 2.0 * Integer.MAX_VALUE) {
// Too far in positive X direction to represent...
// We cannot even reach the left side of the specified
// rectangle even with both x & width set to MAX_VALUE.
// The intersection with the "maximal integer rectangle"
// is non-existant so we should use a width < 0.
// REMIND:Should we try to determine a more "meaningful"
// adjusted value for neww than just "-1"?
newx = Integer.MAX_VALUE;
neww = -1;
} else {
newx = clip(x,false);
if (width >= 0) width += x-newx;
neww = clip(width,width >= 0);
}
if (y > 2.0 * Integer.MAX_VALUE) {
// Too far in positive Y direction to represent...
newy = Integer.MAX_VALUE;
newh = -1;
} else {
newy = clip(y,false);
if (height >= 0) height += y-newy;
newh = clip(height,height >= 0);
}
试了一下效果一样 那不是多此一举 setRect底层多了这些看不懂
int newx,newy,neww,newh;
if (x > 2.0 * Integer.MAX_VALUE) {
// Too far in positive X direction to represent...
// We cannot even reach the left side of the specified
// rectangle even with both x & width set to MAX_VALUE.
// The intersection with the "maximal integer rectangle"
// is non-existant so we should use a width < 0.
// REMIND:Should we try to determine a more "meaningful"
// adjusted value for neww than just "-1"?
newx = Integer.MAX_VALUE;
neww = -1;
} else {
newx = clip(x,false);
if (width >= 0) width += x-newx;
neww = clip(width,width >= 0);
}
if (y > 2.0 * Integer.MAX_VALUE) {
// Too far in positive Y direction to represent...
newy = Integer.MAX_VALUE;
newh = -1;
} else {
newy = clip(y,false);
if (height >= 0) height += y-newy;
newh = clip(height,height >= 0);
}
![java 中 Rectangle 类 的setRect 和setBounds 有什么区别么?](/uploads/image/z/17264138-50-8.jpg?t=java+%E4%B8%AD+Rectangle+%E7%B1%BB+%E7%9A%84setRect+%E5%92%8CsetBounds+%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%E4%B9%88%3F)
都可以的,你方便用哪个、就用那个
为什么JAVA中已经有rectangle类还可以自己定义rectangle类
Java中JFram和Container有什么区别
在JAVA语言中,parseInt(window.prompt(.));和单独的prompt(...)有什么区别?
java中 Color类中的RED和red有什么区别
java中throw和throws的区别
JAVA 中super 和this 的区别?
JAVA中implement和extends的区别?
Java的Calendar类中的常量DAY_OF_WEEK和DAY_OF_WEEK_IN_MONTH有什么区别?
如何用java编写类 Circle(圆) 和类 Rectangle(矩形) ,
java中throw跟throws有什么区别?
java中,集合类有什么作用?
Java中的Double.valueOf()和Double.parseDouble()有什么区别?