• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Button类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getComponentRegistry

import com.codename1.ui.Button; //导入依赖的package包/类
static Hashtable getComponentRegistry() {
    if(componentRegistry == null) {
        componentRegistry = new Hashtable();
        componentRegistry.put("Button", Button.class);
        componentRegistry.put("Calendar", com.codename1.ui.Calendar.class);
        componentRegistry.put("CheckBox", CheckBox.class);
        componentRegistry.put("ComboBox", ComboBox.class);
        componentRegistry.put("Container", Container.class);
        componentRegistry.put("Dialog", Dialog.class);
        componentRegistry.put("Form", Form.class);
        componentRegistry.put("Label", Label.class);
        componentRegistry.put("List", List.class);
        componentRegistry.put("RadioButton", RadioButton.class);
        componentRegistry.put("Slider", Slider.class);
        componentRegistry.put("Tabs", Tabs.class);
        componentRegistry.put("TextArea", TextArea.class);
        componentRegistry.put("TextField", TextField.class);
        componentRegistry.put("EmbeddedContainer", EmbeddedContainer.class);
    }
    return componentRegistry;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:UIBuilder.java


示例2: 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


示例3: removeTitleCommandFromComponent

import com.codename1.ui.Button; //导入依赖的package包/类
private void removeTitleCommandFromComponent(Form f, Container c)
{
    // Some trigger deletes a bunch of components. I have to always keep the count updated.
    for (int i = 0; i < c.getComponentCount(); i++) {
        Component current = c.getComponentAt(i);
        
        if (current instanceof Container) {
            removeTitleCommandFromComponent(f, (Container) current);
        }

        if (current instanceof Button && current.getClientProperty("TitleCommand") != null) {
            Button btn = (Button)current;
            c.removeComponent(current);
            c.revalidate();
            f.removeCommand(btn.getCommand());
            i--;
        }
    }
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:20,代码来源:StateMachine.java


示例4: refreshGrid

import com.codename1.ui.Button; //导入依赖的package包/类
private void refreshGrid(final Container grid) {
    WebServiceProxy.listPhotosAsync(new Callback<long[]>() {
        public void onSucess(long[] value) {
            grid.removeAll();
            imageList = new ImageList(value);
            for(int iter = 0 ; iter < value.length ; iter++) {
                long p = value[iter];
                final Button btn = createImageButton(p, grid, iter);
                grid.addComponent(btn);
            }
            if(!animating) {
                animating = true;
                grid.animateLayoutAndWait(400);
                animating = false;
            }
        }

        public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
            if(Dialog.show("Error", "There was an error fetching the images", "Retry", "Exit")) {
                showMainForm();
            } else {
                Display.getInstance().exitApplication();
            }
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:27,代码来源:PhotoShare.java


示例5: createImageButton

import com.codename1.ui.Button; //导入依赖的package包/类
Button createImageButton(final long imageId, final Container grid, final int offset) {
    final Button btn = new Button(URLImage.createToFileSystem(placeholder, FileSystemStorage.getInstance().getAppHomePath() + "/Thumb_" + imageId, THUMB_URL_PREFIX + imageId, URLImage.RESIZE_SCALE_TO_FILL));
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            imageList.setSelectedIndex(offset);
            final Container viewerParent = new Container(new LayeredLayout());
            ImageViewer viewer = new ImageViewer(imageList.getItemAt(offset));
            viewerParent.addComponent(viewer);
            Container parent = new Container(new BorderLayout());
            viewerParent.addComponent(parent);
            parent.addComponent(BorderLayout.SOUTH, createToolbar(imageId));
            
            likeCount = new Label("");
            parent.addComponent(BorderLayout.NORTH, likeCount);
            
            
            viewer.setImageList(imageList);
            grid.getParent().replace(grid, viewerParent, CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 300));
            Display.getInstance().getCurrent().setBackCommand(createBackCommand(viewerParent, grid));
        }
    });
    return btn;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:PhotoShare.java


示例6: createToolbar

import com.codename1.ui.Button; //导入依赖的package包/类
Container createToolbar(long imageId) {
    Container toolbar = new Container(new GridLayout(1, 4));
    toolbar.setUIID("Toolbar");
    // notice that the characters in the name of the buttons map to icons in the icon font!
    Button likeButton = new Button("d");
    Button flagButton = new Button("c");
    Button detailsButton = new Button("a");
    final ShareButton shareButton = new ShareButton();
    shareButton.setIcon(null);
    shareButton.setText("b");

    bindShareButtonSelectionListener(shareButton);

    likeButton.setUIID("ToolbarLabel");
    flagButton.setUIID("ToolbarLabel");
    detailsButton.setUIID("ToolbarLabel");
    shareButton.setUIID("ToolbarLabel");
    toolbar.addComponent(likeButton);
    toolbar.addComponent(shareButton);
    toolbar.addComponent(detailsButton);
    toolbar.addComponent(flagButton);

    likeButton.addActionListener(createLikeAction(imageId));
    detailsButton.addActionListener(createDetailsButtonActionListener(imageId));
    return toolbar;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:27,代码来源:PhotoShare.java


示例7: getComponentValue

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Returns the value of the given component, this can be overriden to add support for custom built components
 * 
 * @param cmp the component
 * @return  the object value
 */
protected Object getComponentValue(Component cmp) {
    if(cmp instanceof InputComponent) {
        cmp = ((InputComponent)cmp).getEditor();
    }
    if(cmp instanceof TextArea) {
        return ((TextArea)cmp).getText();
    }
    if(cmp instanceof Picker) {
        ((Picker)cmp).getValue();
    }
    if(cmp instanceof RadioButton || cmp instanceof CheckBox) {
        if(((Button)cmp).isSelected()) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }
    if(cmp instanceof Label) {
        return ((Label)cmp).getText();
    }
    if(cmp instanceof List) {
        return ((List)cmp).getSelectedItem();
    }
    return null;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:Validator.java


示例8: 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


示例9: deregisterAll

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Deregisters all the listeners, happens before a new page is loaded
 */
void deregisterAll() {
    for(Enumeration e=comps.keys();e.hasMoreElements();) {
        Component cmp = (Component)e.nextElement();
        cmp.removeFocusListener(this);
        if (cmp instanceof Button) { // catches Button, CheckBox, RadioButton
            ((Button)cmp).removeActionListener(this);
        } else if (cmp instanceof List) { // catches ComboBox
            ((List)cmp).removeSelectionListener((SelectionListener)listeners.get(cmp));
        } else if (cmp instanceof TextArea) {
            ((TextArea)cmp).removeActionListener(this);
            if (cmp instanceof TextField) {
                ((TextField)cmp).removeDataChangeListener((DataChangedListener)listeners.get(cmp));
            }
        }
    }
    comps=new Hashtable();
    listeners=new Hashtable();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:HTMLEventsListener.java


示例10: getCheckBoxPreferredSize

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public Dimension getCheckBoxPreferredSize(Button cb) {
    if(cb.isToggle()) {
        return getButtonPreferredSize(cb);
    }
    threeImageCache[0] = cb.getMaskedIcon();
    threeImageCache[1] = cb.getRolloverIcon();
    threeImageCache[2] = cb.getPressedIcon();
    if (chkBoxImages != null) {
        return getPreferredSize(cb, threeImageCache, chkBoxImages[0]);
    }
    Dimension d = getPreferredSize(cb, threeImageCache, null);

    // checkbox square needs to be the height and width of the font height even
    // when no text is in the check box this is a good indication of phone DPI
    int checkBoxSquareSize = cb.getStyle().getFont().getHeight();

    // allow for checkboxes without a string within them
    d.setHeight(Math.max(checkBoxSquareSize, d.getHeight()));

    d.setWidth(d.getWidth() + checkBoxSquareSize + cb.getGap());
    return d;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:DefaultLookAndFeel.java


示例11: Progress

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Binds the progress UI to the completion of this request
 *
 * @param title the title of the progress dialog
 * @param request the network request pending
 * @param showPercentage shows percentage on the progress bar
 */
public Progress(String title, ConnectionRequest request, boolean showPercentage) {
    super(title);
    this.request = request;
    SliderBridge b = new SliderBridge(request);
    b.setRenderPercentageOnTop(showPercentage);
    b.setRenderValueOnTop(true);
    setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    addComponent(b);
    Command cancel = new Command(UIManager.getInstance().localize("cancel", "Cancel"));
    if(Display.getInstance().isTouchScreenDevice() || getSoftButtonCount() < 2) {
        // if this is a touch screen device or a blackberry use a centered button
        Button btn = new Button(cancel);
        Container cnt = new Container(new FlowLayout(CENTER));
        cnt.addComponent(btn);
        addComponent(cnt);
    } else {
        // otherwise use a command
        addCommand(cancel);
    }
    setDisposeWhenPointerOutOfBounds(false);
    setAutoDispose(false);
    NetworkManager.getInstance().addProgressListener(this);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:Progress.java


示例12: actionCommand

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
protected void actionCommand(Command cmd) {
    if(Display.getInstance().isTouchScreenDevice() || getSoftButtonCount() < 2) {
        for(int iter = 0 ; iter < getComponentCount() ; iter++) {
            Component c = getComponentAt(iter);
            if(c instanceof Button) {
                c.setEnabled(false);
            }
        }
    } else {
        removeAllCommands();
    }
    // cancel was pressed
    request.kill();
    dispose();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:19,代码来源:Progress.java


示例13: SpanButton

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Constructor accepting default text
 */
public SpanButton(String txt) {
    setUIID("Button");
    setLayout(new BorderLayout());
    text = new TextArea(getUIManager().localize(txt, txt));
    text.setColumns(100);
    text.setUIID("Button");
    text.setEditable(false);
    text.setFocusable(false);
    text.setActAsLabel(true);
    removeBackground(text.getUnselectedStyle());
    removeBackground(text.getSelectedStyle());
    removeBackground(text.getPressedStyle());
    removeBackground(text.getDisabledStyle());
    actualButton = new Button();
    actualButton.setUIID("icon");
    addComponent(BorderLayout.WEST, actualButton);
    addComponent(BorderLayout.CENTER, text);
    setLeadComponent(actualButton);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:SpanButton.java


示例14: wrap

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Wraps the given text field with a UI that will allow us to clear it
 * @param tf the text field
 * @param iconSize size in millimeters for the clear icon, -1 for default size
 * @return a Container that should be added to the UI instead of the actual text field
 */
public static ClearableTextField wrap(final TextArea tf, float iconSize) {
    ClearableTextField cf = new ClearableTextField();
    Button b = new Button("", tf.getUIID());
    if(iconSize > 0) {
        FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR, iconSize);
    } else {
        FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR);
    }
    removeCmpBackground(tf);
    removeCmpBackground(b);
    cf.setUIID(tf.getUIID());
    cf.add(BorderLayout.CENTER, tf);
    cf.add(BorderLayout.EAST, b);
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            tf.stopEditing();
            tf.setText("");
            tf.startEditingAsync();
        }
    });
    return cf;        
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:29,代码来源:ClearableTextField.java


示例15: getCheckBoxPreferredSize

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public Dimension getCheckBoxPreferredSize(Button cb) {
    if(cb.isToggle()) {
        return getButtonPreferredSize(cb);
    }
    if (chkBoxImages != null) {
        return getPreferredSize(cb, new Image[]{cb.getMaskedIcon(), cb.getRolloverIcon(), cb.getPressedIcon()}, chkBoxImages[0]);
    }
    Dimension d = getPreferredSize(cb, new Image[]{cb.getMaskedIcon(), cb.getRolloverIcon(), cb.getPressedIcon()}, null);

    // checkbox square needs to be the height and width of the font height even
    // when no text is in the check box this is a good indication of phone DPI
    int checkBoxSquareSize = cb.getStyle().getFont().getHeight();

    // allow for checkboxes without a string within them
    d.setHeight(Math.max(checkBoxSquareSize, d.getHeight()));

    d.setWidth(d.getWidth() + checkBoxSquareSize + cb.getGap());
    return d;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:DefaultLookAndFeel.java


示例16: getRadioButtonPreferredSize

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public Dimension getRadioButtonPreferredSize(Button rb) {
    if(rb.isToggle()) {
        return getButtonPreferredSize(rb);
    }
    if (rButtonImages != null) {
        return getPreferredSize(rb, new Image[]{rb.getMaskedIcon(), rb.getRolloverIcon(), rb.getPressedIcon()}, rButtonImages[0]);
    }
    Dimension d = getPreferredSize(rb, new Image[]{rb.getMaskedIcon(), rb.getRolloverIcon(), rb.getPressedIcon()}, null);

    // radio button radius needs to be of the size of the font height even
    // when no text is in the radio button this is a good indication of phone DPI
    int height = rb.getStyle().getFont().getHeight();

    // allow for radio buttons without a string within them
    d.setHeight(Math.max(height, d.getHeight()));

    d.setWidth(d.getWidth() + height + rb.getGap());
    return d;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:DefaultLookAndFeel.java


示例17: actionCommand

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * @inheritDoc
 */
protected void actionCommand(Command cmd) {
    if(Display.getInstance().isTouchScreenDevice() || getSoftButtonCount() < 2) {
        for(int iter = 0 ; iter < getComponentCount() ; iter++) {
            Component c = getComponentAt(iter);
            if(c instanceof Button) {
                c.setEnabled(false);
            }
        }
    } else {
        removeAllCommands();
    }
    // cancel was pressed
    request.kill();
    dispose();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:Progress.java


示例18: SpanButton

import com.codename1.ui.Button; //导入依赖的package包/类
/**
 * Constructor accepting default text
 */
public SpanButton(String txt) {
    setUIID("Button");
    setLayout(new BorderLayout());
    text = new TextArea(getUIManager().localize(txt, txt));
    text.setColumns(100);
    text.setUIID("Button");
    text.setEditable(false);
    text.setFocusable(false);
    removeBackground(text.getUnselectedStyle());
    removeBackground(text.getSelectedStyle());
    removeBackground(text.getPressedStyle());
    removeBackground(text.getDisabledStyle());
    actualButton = new Button();
    actualButton.setUIID("icon");
    addComponent(BorderLayout.WEST, actualButton);
    addComponent(BorderLayout.CENTER, text);
    setLeadComponent(actualButton);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SpanButton.java


示例19: buildMenuCommand

import com.codename1.ui.Button; //导入依赖的package包/类
private Command buildMenuCommand(String title, String icon, ActionListener listener)
{
    Button l = new Button(title);

    //Image iconImage = StateMachine.getResourceFile().getImage(icon);
    //iconImage.lock();
    //l.setIcon(iconImage);
    l.setGap(20);
    //l.setUIID("NavigationButton");
    l.addActionListener(listener);

    Command c = new Command(title);
    c.putClientProperty("SideComponent", l);

    return c;
}
 
开发者ID:martijn00,项目名称:Zipato,代码行数:17,代码来源:SideMenuView.java


示例20: onQueueAction

import com.codename1.ui.Button; //导入依赖的package包/类
public void onQueueAction(Component c, ActionEvent event) 
{
    event.consume();
    final List list = (List) event.getSource();
    final Map item = (Map)list.getSelectedItem();

    Button clickedButton = ((GenericListCellRenderer)list.getRenderer()).extractLastClickedComponent();
    if (clickedButton != null) {
        // Occurs when touching a button

        if (clickedButton.getName().equals("btnMediaActionFixed")) {
            ArrayList<Command> commands = new ArrayList<Command>();

            Image icon = StateMachine.getResourceFile().getImage("popup_trash_icon.png");
            icon.lock();
            commands.add(new Command(ui.translate("command_remove_item_from_playlist", "[default]Remove item"), icon) {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    ui.player.removeFromQueue((Map) list.getSelectedItem());
                    if(ui.player.isQueueEmpty())
                    {
                        Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createEmpty());
                        ui.playerView.setFromMiniPlayer(false);
                        ui.back();
                        ui.back();
                    }
                    else
                        initQueueModel(list);
                }
            });
            ui.dialogOptions.show(commands);
            return;
        }
    }
    
    ui.player.setQueueAndPlay((TrackListModel) list.getModel());
    Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createFade(200));
    ui.back();
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:41,代码来源:QueueView.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AugmentationsImpl类代码示例发布时间:2022-05-23
下一篇:
Java INVOKESPECIAL类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap