【初心者】Java質問・相談スレッド101【大歓迎】
at TECH
208:189
07/05/06 22:07:18
>>207
こうでしょうか?
synchronized public void mouseDragged(MouseEvent evt) {
if (shapeBeingDragged == null) return;
int x = evt.getX();
int y = evt.getY();
Dimension cs = this.getSize();
int maxw = cs.width - shapeBeingDragged.width;
int maxh = cs.height - shapeBeingDragged.height;
if (x < 0) x = 0; else if (x > maxw) x = maxw;
if (y < 0) y = 0; else if (y > maxh) y = maxh;
shapeBeingDragged.moveBy(x, y);
repaint();
}
synchronized public void mouseReleased(MouseEvent evt) {
if (shapeBeingDragged == null) return;
int x = evt.getX();
int y = evt.getY();
Dimension cs = this.getSize();
int maxw = cs.width - shapeBeingDragged.width;
int maxh = cs.height - shapeBeingDragged.height;
if (x < 0) x = 0; else if (x > maxw) x = maxw;
if (y < 0) y = 0; else if (y > maxh) y = maxh;
shapeBeingDragged.moveBy(x, y);
shapeBeingDragged = null;
repaint();
}
URLリンク(a-draw.com)
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5372日前に更新/271 KB
担当:undef