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


Java Form.addCommand方法代码示例

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


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

示例1: addFormCommand

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void addFormCommand(Form f)
{
    Image icon = StateMachine.getResourceFile().getImage("player_player_icon.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("player_player_icon_active.png");
    iconPressed.lock();
    Command titleCmd = new Command(null, icon) {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createFade(200));
            ui.back();
        }
    };

    titleCmd.setPressedIcon(iconPressed);
    titleCmd.putClientProperty("TitleCommand", Boolean.TRUE);

    f.addCommand(titleCmd);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:20,代码来源:QueueView.java

示例2: addPlaylistEdit

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void addPlaylistEdit(final Form f)
{
    //TODO: Enabled this again when Shai has fixed deleting titlecommands
    //if(titleCommand != null)
    //    f.removeCommand(titleCommand);
    
    ui.removeTitleCommand(f);
    
    // Add command to change playlist-name
    Image icon = StateMachine.getResourceFile().getImage("playlist_edit_static.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_edit_active.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            
            addPlaylistCancel(f);
            
            onEditPlaylistTitle(f);
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:27,代码来源:PlaylistView.java

示例3: addPlaylistCancel

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void addPlaylistCancel(final Form f)
{
    //f.removeCommand(titleCommand);
    ui.removeTitleCommand(f);
    
    
    // Add command to change playlist-name
    Image icon = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistEdit(f);
            hideTopbarEditing(f);
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:23,代码来源:PlaylistView.java

示例4: addPlaylistAdd

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void addPlaylistAdd(final Form f)
{
    //TODO: Enabled this again when Shai has fixed deleting titlecommands
    //if(titleCommand != null)
    //   f.removeCommand(titleCommand);
    
    ui.removeTitleCommand(f);
    
    Image icon = StateMachine.getResourceFile().getImage("playlist_plus_static.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_plus_active.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistCancel(f);
            ui.resetComponentHeight(ui.findCtnAddPlaylistForm(f));
            ui.findTfdAddPlaylistFormTitle(f).requestFocus();
            Display.getInstance().editString(ui.findTfdAddPlaylistFormTitle(f), 200, TextField.ANY, "");
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:26,代码来源:PlaylistOverviewView.java

示例5: addPlaylistCancel

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void addPlaylistCancel(final Form f)
{
    ui.removeTitleCommand(f);
    
    Image icon = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistAdd(f);
            ui.hideComponent(ui.findCtnAddPlaylistForm(f));
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:20,代码来源:PlaylistOverviewView.java

示例6: showMainForm

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void showMainForm() {
    final Form photos = new Form("Photos");
    photos.setLayout(new BorderLayout());
    GridLayout gr = new GridLayout(1, 1);
    final Container grid = new Container(gr);
    gr.setAutoFit(true);
    grid.setScrollableY(true);
    grid.addPullToRefresh(new Runnable() {
        public void run() {
            refreshGrid(grid);
        }
    });

    grid.addComponent(new InfiniteProgress());
    photos.addComponent(BorderLayout.CENTER, grid);

    photos.removeAllCommands();
    photos.setBackCommand(null);
    photos.addCommand(createPictureCommand(grid));

    photos.show();
    refreshGrid(grid);
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:PhotoShare.java

示例7: showAuthentication

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * This method shows an authentication for login form
 *
 * @param al a listener that will receive at its source either a token for
 * the service or an exception in case of a failure
 * @return a component that should be displayed to the user in order to
 * perform the authentication
 */
public void showAuthentication(ActionListener al) {
    final Form old = Display.getInstance().getCurrent();
    InfiniteProgress inf = new InfiniteProgress();
    final Dialog progress = inf.showInifiniteBlocking();
    Form authenticationForm = new Form("Login");
    authenticationForm.setScrollable(false);
    if (old != null) {
        Command cancel = new Command("Cancel") {
            public void actionPerformed(ActionEvent ev) {
                if (Display.getInstance().getCurrent() == progress) {
                    progress.dispose();
                }
                old.showBack();
            }
        };
        if (authenticationForm.getToolbar() != null){
            authenticationForm.getToolbar().addCommandToLeftBar(cancel);
        } else {
            authenticationForm.addCommand(cancel);
        }
        authenticationForm.setBackCommand(cancel);
    }
    authenticationForm.setLayout(new BorderLayout());
    authenticationForm.addComponent(BorderLayout.CENTER, createLoginComponent(al, authenticationForm, old, progress));
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:34,代码来源:Oauth2.java

示例8: showLog

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * Places a form with the log as a TextArea on the screen, this method can
 * be attached to appear at a given time or using a fixed global key. Using
 * this method might cause a problem with further log output
 * @deprecated this method is an outdated method that's no longer supported
 */
public static void showLog() {
    try {
        String text = getLogContent();
        TextArea area = new TextArea(text, 5, 20);
        Form f = new Form("Log");
        f.setScrollable(false);
        final Form current = Display.getInstance().getCurrent();
        Command back = new Command("Back") {
            public void actionPerformed(ActionEvent ev) {
                current.show();
            }
        };
        f.addCommand(back);
        f.setBackCommand(back);
        f.setLayout(new BorderLayout());
        f.addComponent(BorderLayout.CENTER, area);
        f.show();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:28,代码来源:Log.java

示例9: setBackCommand

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * Invoked internally to set the back command on the form, this method allows subclasses
 * to change the behavior of back command adding or disable it
 * @param f the form
 * @param backCommand the back command 
 */
protected void setBackCommand(Form f, Command backCommand) {
    if(f.getToolbar() != null) {
        f.getToolbar().setBackCommand(backCommand);
    } else {
        if(shouldAddBackCommandToMenu()) {
            f.addCommand(backCommand, f.getCommandCount());
        }
        f.setBackCommand(backCommand);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:UIBuilder.java

示例10: reloadForm

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * Useful tool to refresh the current state of a form shown using show form
 * without pushing another instance to the back stack
 */
public void reloadForm() {
    Form currentForm = Display.getInstance().getCurrent();
    Command backCommand = currentForm.getBackCommand(); 
    Form newForm = (Form)createContainer(fetchResourceFile(), currentForm.getName());

    if (backCommand != null) {
        setBackCommand(newForm, backCommand);

        // trigger listener creation if this is the only command in the form
        getFormListenerInstance(newForm, null);
        
        for(int iter = 0 ; iter < currentForm.getCommandCount() ; iter++) {
            if(backCommand == currentForm.getCommand(iter)) {
                newForm.addCommand(backCommand, newForm.getCommandCount());
                break;
            }
        }
    }
    
    beforeShow(newForm);
    Transition tin = newForm.getTransitionInAnimator();
    Transition tout = newForm.getTransitionOutAnimator();
    currentForm.setTransitionInAnimator(CommonTransitions.createEmpty());
    currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
    newForm.setTransitionInAnimator(CommonTransitions.createEmpty());
    newForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
    newForm.layoutContainer();
    newForm.show();
    postShowImpl(newForm);
    newForm.setTransitionInAnimator(tin);
    newForm.setTransitionOutAnimator(tout);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:37,代码来源:UIBuilder.java

示例11: buildOfflineMenu

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void buildOfflineMenu(final Form f)
{
    if(offlineSideCommands.isEmpty() || !Language.getInstance().getCurrentLanguage().equals(menuAppLanguage))
    {
        offlineSideCommands.clear();
        menuAppLanguage = Language.getInstance().getCurrentLanguage();

        offlineSideCommands.add(buildCommand(
                ui.translate("menu_playlists", "[default]My Playlists"),
                "nav_playlist.png",
                PlaylistOverviewView.FORM_NAME,
                new Runnable() {
                    public void run() {
                        ui.playlistOverviewView.show();
                    }
                }
        ));

        offlineSideCommands.add(buildCommand(
                ui.translate("menu_settings", "[default]Settings"),
                "nav_settings.png",
                SettingsView.FORM_NAME,
                new Runnable() {
                    public void run() {
                        ui.settingsView.show();
                    }
                }
        ));

        String offlineText;
        if(Api.getInstance().hasProfile())
            offlineText = ui.translate("menu_go_online", "[default] Go online again");
        else
            offlineText = ui.translate("login_button_login", "[default] Log in");
        
        offlineSideCommands.add(buildCommand(
                offlineText,
                "nav_go_online.png",
                null,
                new Runnable() {
                    public void run() {
                        StateMachine.goOnline();
                    }
                }
        ));
    }
    
    for(Command cmd : offlineSideCommands)
    {
        f.addCommand(cmd);
    }
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:53,代码来源:SideMenu.java

示例12: bindTabletLandscapeMaster

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * @deprecated this was a half baked idea that made it into the public API
 */
public static void bindTabletLandscapeMaster(final Form rootForm, Container parentContainer, Component landscapeUI, final Component portraitUI, final String commandTitle, Image commandIcon) {
    landscapeUI.setHideInPortrait(true);
    parentContainer.addComponent(BorderLayout.WEST, landscapeUI);

    final Command masterCommand = new Command(commandTitle, commandIcon) {
        public void actionPerformed(ActionEvent ev) {
            Dialog dlg = new Dialog();
            dlg.setLayout(new BorderLayout());
            dlg.setDialogUIID("Container");
            dlg.getContentPane().setUIID("Container");
            Container titleArea = new Container(new BorderLayout());
            dlg.addComponent(BorderLayout.NORTH, titleArea);
            titleArea.setUIID("TitleArea");
            Label title = new Label(commandTitle);
            titleArea.addComponent(BorderLayout.CENTER, title);
            title.setUIID("Title");
            Container body = new Container(new BorderLayout());
            body.setUIID("Form");
            body.addComponent(BorderLayout.CENTER, portraitUI);
            dlg.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 250));
            dlg.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 250));
            dlg.addComponent(BorderLayout.CENTER, body);
            dlg.setDisposeWhenPointerOutOfBounds(true);
            dlg.showStetched(BorderLayout.WEST, true);
            dlg.removeComponent(portraitUI);
        }
    };
    if(Display.getInstance().isPortrait()) {
        if(rootForm.getCommandCount() > 0) {
            rootForm.addCommand(masterCommand, 1);
        } else {
            rootForm.addCommand(masterCommand);                
        }
    }
    rootForm.addOrientationListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if(portraitUI.getParent() != null) {
                Form f = Display.getInstance().getCurrent();
                if(f instanceof Dialog) {
                    ((Dialog)f).dispose();
                }
            }
            if(Display.getInstance().isPortrait()) {
                rootForm.addCommand(masterCommand, 1);
            } else {
                rootForm.removeCommand(masterCommand);
                rootForm.revalidate();
            }
        }
    });        
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:55,代码来源:MasterDetail.java


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