本文整理汇总了Java中com.codename1.ui.Button.putClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Button.putClientProperty方法的具体用法?Java Button.putClientProperty怎么用?Java Button.putClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.ui.Button
的用法示例。
在下文中一共展示了Button.putClientProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dealCard
import com.codename1.ui.Button; //导入方法依赖的package包/类
/**
* A blocking method that creates the card deal animation and binds the drop logic when cards are dropped on the deck
*/
private void dealCard(Component deck, final Container destination, Image cardImage, Card currentCard) {
final Button card = new Button();
card.setUIID("Label");
card.setIcon(cardImage);
// Components are normally placed by layout managers so setX/Y/Width/Height shouldn't be invoked. However,
// in this case we want the layout animation to deal from a specific location. Notice that we use absoluteX/Y
// since the default X/Y are relative to their parent container.
card.setX(deck.getAbsoluteX());
int deckAbsY = deck.getAbsoluteY();
if(destination.getY() > deckAbsY) {
card.setY(deckAbsY - destination.getAbsoluteY());
} else {
card.setY(deckAbsY);
}
card.setWidth(deck.getWidth());
card.setHeight(deck.getHeight());
destination.addComponent(card);
// we save the model data directly into the component so we don't need to keep track of it. Later when we
// need to check the card type a user touched we can just use getClientProperty
card.putClientProperty("card", currentCard);
destination.getParent().animateHierarchyAndWait(400);
card.setDraggable(true);
// when the user drops a card on a drop target (currently only the deck) we remove it and animate it out
card.addDropListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
evt.consume();
card.getParent().removeComponent(card);
destination.animateLayout(300);
}
});
}