本文整理汇总了Java中com.codename1.ui.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于com.codename1.ui包,在下文中一共展示了Command类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addFormCommand
import com.codename1.ui.Command; //导入依赖的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: addBackCommand
import com.codename1.ui.Command; //导入依赖的package包/类
public void addBackCommand(Form f)
{
Image icon = StateMachine.getResourceFile().getImage("back_static.png");
icon.lock();
Image iconPressed = StateMachine.getResourceFile().getImage("back_active.png");
iconPressed.lock();
Command backCommand = new Command(null, icon){
@Override
public void actionPerformed(ActionEvent ev) {
ui.back();
}
};
backCommand.setPressedIcon(iconPressed);
f.setBackCommand(backCommand);
}
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:17,代码来源:SideMenu.java
示例3: buildCommand
import com.codename1.ui.Command; //导入依赖的package包/类
private Command buildCommand(String text, String iconKey, final String formName, final Runnable runnable)
{
Command cmd = new Command(text, StateMachine.getResourceFile().getImage(iconKey)) {
@Override
public void actionPerformed(ActionEvent evt) {
SideMenuBar.closeCurrentMenu(new Runnable() {
@Override
public void run() {
if(formName == null || (Display.getInstance().getCurrent() != null && !formName.equals(Display.getInstance().getCurrent().getName())))
{
Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createEmpty());
runnable.run();
}
}
});
}
};
cmd.putClientProperty("uiid", "NavigationButton");
cmd.putClientProperty("iconGap", 20);
return cmd;
}
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:24,代码来源:SideMenu.java
示例4: addPlaylistEdit
import com.codename1.ui.Command; //导入依赖的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
示例5: addPlaylistCancel
import com.codename1.ui.Command; //导入依赖的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
示例6: addPlaylistAdd
import com.codename1.ui.Command; //导入依赖的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
示例7: addPlaylistCancel
import com.codename1.ui.Command; //导入依赖的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
示例8: getShareCommand
import com.codename1.ui.Command; //导入依赖的package包/类
public static Command getShareCommand(final Map item)
{
Image iconShare = StateMachine.getResourceFile().getImage("popup_facebook_icon.png");
return new Command(StateMachine._translate("command_share_item", "[default]Share"), iconShare) {
@Override
public void actionPerformed(ActionEvent evt) {
String shareText;
//When item is a performer
if(item.get("name") != null)
shareText = "I listened to " + item.get("name") + " on Music Player";
//When item is a category
else if(item.get("categories") != null)
shareText = "I visited the category " + item.get("title") + " on Music Player";
//When item is an album
else if(item.get("tracks") != null)
shareText = "I listened to the album " + item.get("title") + " on Music Player";
//When item is a track
else
shareText = "I listened to " + item.get("lblTitle") + " - " + item.get("lblSecondaryTitle") + " on Music Player";
Display.getInstance().share(shareText, null, "text/plain");
}
};
}
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:25,代码来源:DialogOptions.java
示例9: getMenu
import com.codename1.ui.Command; //导入依赖的package包/类
public Menu getMenu(int val) {
if (Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE) {
m = new Menu();
if(commands != null){
for (int iter = 0; iter < commands.size(); iter++) {
final Command cmd = (Command) commands.elementAt(iter);
String txt = UIManager.getInstance().localize(cmd.getCommandName(), cmd.getCommandName());
MenuItem i = new MenuItem(txt, iter, iter) {
public void run() {
Display.getInstance().callSerially(new Runnable() {
public void run() {
impl.getCurrentForm().dispatchCommand(cmd, new ActionEvent(cmd));
}
});
}
};
m.add(i);
}
}
return m;
}
return super.getMenu(val);
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:BlackBerryCanvas.java
示例10: processCommandImpl
import com.codename1.ui.Command; //导入依赖的package包/类
private void processCommandImpl(ActionEvent ev, Command cmd) {
processCommand(ev, cmd);
if(ev.isConsumed()) {
return;
}
if(globalCommandListeners != null) {
globalCommandListeners.fireActionEvent(ev);
if(ev.isConsumed()) {
return;
}
}
if(localCommandListeners != null) {
Form f = Display.getInstance().getCurrent();
EventDispatcher e = (EventDispatcher)localCommandListeners.get(f.getName());
if(e != null) {
e.fireActionEvent(ev);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:UIBuilder.java
示例11: initBackForm
import com.codename1.ui.Command; //导入依赖的package包/类
private void initBackForm(Form f) {
Vector formNavigationStack = baseFormNavigationStack;
if(formNavigationStack != null && formNavigationStack.size() > 0) {
setFormState(f, (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1));
formNavigationStack.removeElementAt(formNavigationStack.size() - 1);
if(formNavigationStack.size() > 0) {
Hashtable previous = (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1);
String commandAction = (String)previous.get(FORM_STATE_KEY_NAME);
Command backCommand = createCommandImpl(getBackCommandText((String)previous.get(FORM_STATE_KEY_TITLE)), null,
BACK_COMMAND_ID, commandAction, true, "");
setBackCommand(f, backCommand);
// trigger listener creation if this is the only command in the form
getFormListenerInstance(f, null);
backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
backCommand.putClientProperty(COMMAND_ACTION, commandAction);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:UIBuilder.java
示例12: createBackLazyValue
import com.codename1.ui.Command; //导入依赖的package包/类
/**
* This is useful for swipe back navigation behavior
* @param f the form from which we should go back
* @return a lazy value that will return the back form
*/
public LazyValue<Form> createBackLazyValue(final Form f) {
Vector formNavigationStack = baseFormNavigationStack;
Hashtable p = null;
Command cmd = null;
if(formNavigationStack.size() > 1) {
p = (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 2);
String backTitle = getBackCommandText((String)p.get(FORM_STATE_KEY_TITLE));
String commandAction = (String)p.get(FORM_STATE_KEY_NAME);
cmd = createCommandImpl(backTitle, null,
BACK_COMMAND_ID, commandAction, true, "");
cmd.putClientProperty(COMMAND_ARGUMENTS, "");
cmd.putClientProperty(COMMAND_ACTION, commandAction);
}
return new LazyValueC(f, p, cmd, this);
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:UIBuilder.java
示例13: showAuthentication
import com.codename1.ui.Command; //导入依赖的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
示例14: showLog
import com.codename1.ui.Command; //导入依赖的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
示例15: Progress
import com.codename1.ui.Command; //导入依赖的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
示例16: actionCommand
import com.codename1.ui.Command; //导入依赖的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
示例17: createForm
import com.codename1.ui.Command; //导入依赖的package包/类
private Form createForm(String title, Component content){
Form f = new Form(title);
f.setLayout(new BorderLayout());
f.addComponent(BorderLayout.CENTER, content);
if (!"Main Menu".equals(title)){
f.setBackCommand(new Command("Main Menu"){
@Override
public void actionPerformed(ActionEvent evt) {
createForm("Main Menu", getMainMenu()).showBack();
}
});
}
return f;
}
开发者ID:shannah,项目名称:CN1ML-NetbeansModule,代码行数:17,代码来源:CN1MLDemo.java
示例18: showAuthentication
import com.codename1.ui.Command; //导入依赖的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();
}
};
authenticationForm.addCommand(cancel);
authenticationForm.setBackCommand(cancel);
}
authenticationForm.setLayout(new BorderLayout());
authenticationForm.addComponent(BorderLayout.CENTER, createLoginComponent(al, authenticationForm, old, progress));
}
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:Oauth2.java
示例19: showLog
import com.codename1.ui.Command; //导入依赖的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
*/
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:shannah,项目名称:cn1,代码行数:27,代码来源:Log.java
示例20: actionCommand
import com.codename1.ui.Command; //导入依赖的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
注:本文中的com.codename1.ui.Command类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论