繁体   English   中英

java imageicon放在最前面

[英]java imageicon bring to front

我有一张卡片清单,它们有一个图像图标,我在甲板上都画了所有卡片,我可以用mousePressed和mouseDragged移动它们,现在我想在单击卡片时将卡片放在前面,在其他卡片的后面,当我单击它时,它移到所有卡片的前面。 我该怎么做呢?

这是我按下鼠标的代码:

int x = e.getX();   // Save the x coord of the click
int y = e.getY();   // Save the y coord of the click

//... Find card image this is in.  Check from top down.
_currentCard = null;  // Assume not in any image.
for (int crd=_deck.length-1; crd>=0; crd--) {
    Card testCard = _deck[crd];
    if (testCard.contains(x, y)) {
        //... Found, remember this card for dragging.
        _dragFromX = x - testCard.getX();  // how far from left
        _dragFromY = x - testCard.getY();  // how far from top
         _currentCard = testCard; // Remember what we're dragging.

        break;        // Stop when we find the first match.
    }
}

使用ArrayList并从列表中删除选定的卡,然后将其重新添加到顶部。 然后按照列表顺序绘制卡。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM