use of org.magic.game.transfert.CardTransfertHandler in project MtgDesktopCompanion by nicho92.
the class DisplayableCard method construct.
public void construct(MagicCard mc, Dimension d, boolean activateCards, boolean rightClick) {
rightActions = rightClick;
menu = new JPopupMenu();
sep = new JSeparator();
attachedCards = new ArrayList<>();
obs = new Observable();
counters = new ArrayList<>();
setSize(d);
setPreferredSize(d);
setHorizontalAlignment(JLabel.CENTER);
setVerticalAlignment(JLabel.CENTER);
try {
setMagicCard((MagicCard) BeanUtils.cloneBean(mc));
} catch (Exception e1) {
MTGLogger.printStackTrace(e1);
}
if (activateCards) {
addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
describe();
}
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
if (e.getClickCount() == 1 && e.isControlDown()) {
setSelected(!isSelected());
repaint();
}
if (e.getClickCount() == 2) {
if (isTappable())
tap(!isTapped());
return;
}
}
}
});
addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && isDraggable())
enableDrag(e);
}
});
}
initActions();
setTransferHandler(new CardTransfertHandler());
}
Aggregations