当前位置: 首页>>代码示例>>Java>>正文


Java Button.setIcon方法代码示例

本文整理汇总了Java中com.codename1.ui.Button.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setIcon方法的具体用法?Java Button.setIcon怎么用?Java Button.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.codename1.ui.Button的用法示例。


在下文中一共展示了Button.setIcon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateRepeatButton

import com.codename1.ui.Button; //导入方法依赖的package包/类
private void updateRepeatButton(Form f) {
    final Button repeatBtn = ui.findBtnPlayerRepeat(f);
    if (repeatBtn == null) {
        return;
    }

    Image icon = StateMachine.getResourceFile().getImage(
            ui.player.getRepeat()
            ? "player_repeat_active.png"
            : "player_repeat.png");

    icon.lock();
    repeatBtn.setIcon(icon);

    updateSelection(f);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:17,代码来源:PlayerView.java

示例2: createNodeComponent

import com.codename1.ui.Button; //导入方法依赖的package包/类
/**
 * Creates a node within the tree, this method is protected allowing tree to be
 * subclassed to replace the rendering logic of individual tree buttons.
 *
 * @param node the node object from the model to display on the button
 * @param depth the depth within the tree (normally represented by indenting the entry)
 * @return a button representing the node within the tree
 * @deprecated replaced with createNode, bindNodeListener and setNodeIcon
 */
protected Button createNodeComponent(Object node, int depth) {
    Button cmp = new Button(childToDisplayLabel(node));
    cmp.setUIID("TreeNode");
    if(model.isLeaf(node)) {
        if(nodeImage == null) {
            FontImage.setMaterialIcon(cmp, FontImage.MATERIAL_DESCRIPTION, 3);
        } else {
            cmp.setIcon(nodeImage);
        }
    } else {
        if(folder == null) {
            FontImage.setMaterialIcon(cmp, FontImage.MATERIAL_FOLDER, 3);
        } else {
            cmp.setIcon(folder);
        }
    }
    updateNodeComponentStyle(cmp.getSelectedStyle(), depth);
    updateNodeComponentStyle(cmp.getUnselectedStyle(), depth);
    updateNodeComponentStyle(cmp.getPressedStyle(), depth);
    return cmp;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:Tree.java

示例3: updateShuffleButton

import com.codename1.ui.Button; //导入方法依赖的package包/类
private void updateShuffleButton(Form f, Boolean shuffle) {
    final Button shuffleBtn = ui.findBtnPlayerShuffle(f);
    if (shuffleBtn == null) {
        return;
    }

    Image icon = StateMachine.getResourceFile().getImage(
            shuffle
            ? "player_shuffle_active.png"
            : "player_shuffle.png");

    icon.lock();
    shuffleBtn.setIcon(icon);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:15,代码来源:PlayerView.java

示例4: showLoginForm

import com.codename1.ui.Button; //导入方法依赖的package包/类
private void showLoginForm() {
    Form loginForm = new Form();
    loginForm.getTitleArea().setUIID("Container");
    loginForm.setLayout(new BorderLayout());
    loginForm.setUIID("MainForm");
    Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
    cnt.setUIID("Padding");
    Button loginWithGoogle = new Button("Signin with Google");
    loginWithGoogle.setUIID("LoginButtonGoogle");
    Button loginWithFacebook = new Button("Signin with Facebook");
    loginWithFacebook.setUIID("LoginButtonFacebook");
    Style iconFontStyle = UIManager.getInstance().getComponentStyle("IconFont");
    loginWithFacebook.setIcon(FontImage.create(" \ue96c ", iconFontStyle));
    loginWithGoogle.setIcon(FontImage.create(" \ue976 ", iconFontStyle));
    cnt.addComponent(loginWithGoogle);
    cnt.addComponent(loginWithFacebook);
    loginWithGoogle.addActionListener((e) -> {
        Dialog.show("Test", "Test", "OK", null);
        tokenPrefix = "google";
        Login gc = GoogleConnect.getInstance();
        gc.setScope("profile email https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me");
        gc.setClientId("1013232201263-lf4aib14r7g6mln58v1e36ibhktd79db.apps.googleusercontent.com");
        gc.setRedirectURI("https://www.codenameone.com/oauth2callback");
        gc.setClientSecret("uvu03IXOhx9sO8iPcmDfuX3R");
        doLogin(gc, new GoogleData(), false);
    });
    loginWithFacebook.addActionListener((e) -> {
        tokenPrefix = "facebook";
        Login fb = FacebookConnect.getInstance();
        fb.setClientId("739727009469185");
        fb.setRedirectURI("http://www.codenameone.com/");
        fb.setClientSecret("4c4a7df81a8e9ab29ac4e38e6b9e4eb1");
        doLogin(fb, new FacebookData(), false);
    });
    loginForm.addComponent(BorderLayout.SOUTH, cnt);
    loginForm.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:38,代码来源:SocialChat.java

示例5: 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);
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:38,代码来源:Poker.java

示例6: createNodeComponent

import com.codename1.ui.Button; //导入方法依赖的package包/类
/**
 * Creates a node within the tree, this method is protected allowing tree to be
 * subclassed to replace the rendering logic of individual tree buttons.
 *
 * @param node the node object from the model to display on the button
 * @param depth the depth within the tree (normally represented by indenting the entry)
 * @return a button representing the node within the tree
 * @deprecated replaced with createNode, bindNodeListener and setNodeIcon
 */
protected Button createNodeComponent(Object node, int depth) {
    Button cmp = new Button(childToDisplayLabel(node));
    cmp.setUIID("TreeNode");
    if(model.isLeaf(node)) {
        cmp.setIcon(nodeImage);
    } else {
        cmp.setIcon(folder);
    }
    updateNodeComponentStyle(cmp.getSelectedStyle(), depth);
    updateNodeComponentStyle(cmp.getUnselectedStyle(), depth);
    updateNodeComponentStyle(cmp.getPressedStyle(), depth);
    return cmp;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:Tree.java

示例7: createEntry

import com.codename1.ui.Button; //导入方法依赖的package包/类
/**
 * This method builds a UI Entry dynamically from a data Map object.
 */
private static Component createEntry(Map data, final int index) {
    final Container cnt = new Container(new BorderLayout());
    cnt.setUIID("MultiButton");
    Button icon = new Button();
    icon.setUIID("Label");
    //take the time and use it as the identifier of the image
    String time = (String) data.get("date_taken");
    String link = (String) ((Map) data.get("media")).get("m");

    EncodedImage im = (EncodedImage) res.getImage("flickr.png");
    final URLImage image = URLImage.createToStorage(im, time, link, null);
    icon.setIcon(image);
    icon.setName("ImageButton" + index);
    icon.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            
            Dialog d = new Dialog();
            //d.setDialogUIID("Container");                
            d.setLayout(new BorderLayout());
            Label l = new Label(image);
            l.setUIID("ImagePop");
            d.add(BorderLayout.CENTER, l);
            d.setDisposeWhenPointerOutOfBounds(true);
            d.setTransitionInAnimator(new BubbleTransition(300, "ImageButton" + index));
            d.setTransitionOutAnimator(new BubbleTransition(300, "ImageButton" + index));
            d.show();
        }
    });
    
    cnt.addComponent(BorderLayout.WEST, icon);

    Container center = new Container(new BorderLayout());

    Label des = new Label((String) data.get("title"));
    des.setUIID("MultiLine1");
    center.addComponent(BorderLayout.NORTH, des);
    Label author = new Label((String) data.get("author"));
    author.setUIID("MultiLine2");
    center.addComponent(BorderLayout.SOUTH, author);

    cnt.addComponent(BorderLayout.CENTER, center);
    return cnt;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:48,代码来源:Flickr.java


注:本文中的com.codename1.ui.Button.setIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。