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


Java Form.addComponent方法代码示例

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


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

示例1: createMainForm

import com.codename1.ui.Form; //导入方法依赖的package包/类
public static Form createMainForm() {
    Form main = new Form("Flickr tags");
    main.setLayout(new BorderLayout());
    Toolbar bar = new Toolbar();
    main.setToolBar(bar);
    addCommandsToToolbar(bar);

    TextArea desc = new TextArea();
    desc.setText("This is a Flickr tags demo, the demo uses the Toolbar to arrange the Form Commands.\n\n"
            + "Select \"Cats\" to view the latest photos that were tagged as \"Cats\".\n\n"
            + "Select \"Dogs\" to view the latest photos that were tagged as \"Dogs\".\n\n"
            + "Select \"Search\" to enter your own tags for search.");
    desc.setEditable(false);

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

示例2: wrap

import com.codename1.ui.Form; //导入方法依赖的package包/类
protected Form wrap(String title, Component c){
    c.getStyle().setBgColor(0xff0000);
    Form f = new Form(title);
    f.setLayout(new BorderLayout());
    if (isDrawOnMutableImage()) {
        int dispW = Display.getInstance().getDisplayWidth();
        int dispH = Display.getInstance().getDisplayHeight();
        Image img = Image.createImage((int)(dispW * 0.8), (int)(dispH * 0.8), 0x0);
        Graphics g = img.getGraphics();
        c.setWidth((int)(dispW * 0.8));
        c.setHeight((int)(dispH * 0.8));
        c.paint(g);
        f.addComponent(BorderLayout.CENTER, new Label(img));
    } else {
      f.addComponent(BorderLayout.CENTER, c);
    }
    
    return f;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:AbstractDemoChart.java

示例3: ChartsInBoxLayout

import com.codename1.ui.Form; //导入方法依赖的package包/类
public ChartsInBoxLayout() {
    form = new Form("Charts in Box Layout");
    form.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    
    Component chart1 = getTemperatureChart();
    chart1.getStyle().setBgColor(0x0);
    //chart1.setHeight(300);
    //chart1.setWidth(300);
    chart1.setPreferredH(500);
    
    form.addComponent(chart1);
    Component chart2 = getCombinedTemperatureChart();
    chart2.getStyle().setBgColor(0x0);
    chart2.setPreferredH(500);
    //chart2.setHeight(300);
    //chart2.setWidth(300);
    form.setScrollableY(true);
    form.addComponent(chart2);
    
    
    

}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:ChartsInBoxLayout.java

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

示例5: start

import com.codename1.ui.Form; //导入方法依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Signature Component");
    hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    hi.add("Enter Your Name:");
    hi.add(new TextField());
    hi.add("Signature:");
    SignatureComponent sig = new SignatureComponent();
    sig.addActionListener((evt)-> {
        System.out.println("The signature was changed");
        Image img = sig.getSignatureImage();
        // Now we can do whatever we want with the image of this signature.
    });
    hi.addComponent(sig);
    hi.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:SignatureComponentDemo.java

示例6: CodenameOneComponentWrapper

import com.codename1.ui.Form; //导入方法依赖的package包/类
public CodenameOneComponentWrapper(com.codename1.ui.Component codenameOneCmp, boolean forceShow) {
    this.codenameOneCmp = codenameOneCmp;
    if(codenameOneCmp.getParent() == null) {
        if(!(codenameOneCmp instanceof Form)) {
            Form dummy = new Form("");
            dummy.setLayout(new com.codename1.ui.layouts.BorderLayout());
            dummy.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, codenameOneCmp);
            dummy.setWidth(1000);
            dummy.setHeight(1000);
            dummy.layoutContainer();
            if(forceShow || com.codename1.ui.Display.getInstance().getCurrent() == null) {
                dummy.show();
            }
        } else {
            ((Form)codenameOneCmp).layoutContainer();
            if(com.codename1.ui.Display.getInstance().getCurrent() == null) {
                if(codenameOneCmp instanceof com.codename1.ui.Dialog) {
                    ((com.codename1.ui.Dialog)codenameOneCmp).showModeless();
                } else {
                    ((Form)codenameOneCmp).show();
                }
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:CodenameOneComponentWrapper.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: showFavs

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * Shows the favorites screen 
 */
void showFavs() {
    final Form favsForm = new Form("Favourites");
    addBackToHome(favsForm);
    favsForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    if(favoritesList.size() == 0) {
        favsForm.addComponent(new SpanLabel("You have not added any properties to your favourites"));
    } else {
        // this is really trivial we just take the favorites and show them as a set of buttons
        for(Map<String, Object> c : favoritesList) {
            MultiButton mb = new MultiButton();
            final Map<String, Object> currentListing = c;
            String thumb_url = (String)currentListing.get("thumb_url");
            String guid = (String)currentListing.get("guid");
            String price_formatted = (String)currentListing.get("price_formatted");
            String summary = (String)currentListing.get("summary");
            mb.setIcon(URLImage.createToStorage(placeholder, guid, thumb_url, URLImage.RESIZE_SCALE_TO_FILL));
            mb.setTextLine1(price_formatted);
            mb.setTextLine2(summary);
            mb.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    showPropertyDetails(favsForm, currentListing);
                }
            });
            favsForm.addComponent(mb);
        }
    }
    favsForm.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:32,代码来源:PropertyCross.java

示例10: showLoginForm

import com.codename1.ui.Form; //导入方法依赖的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

示例11: createMorphEffect

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void createMorphEffect(Label titleLabel) {
    // animate the components out of the previous form if we are coming in from the login form
    Form parent = Display.getInstance().getCurrent();
    if(parent.getUIID().equals("MainForm")) {
        for(Component cmp : parent.getContentPane()) {
            cmp.setX(parent.getWidth());
        }
        
        // moves all the components outside of the content pane to the right while fading them out over 400ms
        parent.getContentPane().animateUnlayoutAndWait(400, 0);
        parent.getContentPane().removeAll();
        
        // we can't mutate a form into a component in another form so we need to convert the background to an image and then morph that
        // this is especially easy since we already removed all the components
        Label dummy = new Label();
        dummy.setShowEvenIfBlank(true);
        dummy.setUIID("Container");
        dummy.setUnselectedStyle(new Style(parent.getUnselectedStyle()));
        parent.setUIID("Form");
        
        // special case to remove status bar on iOS 7
        parent.getTitleArea().removeAll();
        parent.setLayout(new BorderLayout());
        parent.addComponent(BorderLayout.CENTER, dummy);
        parent.revalidate();
        
        // animate the main panel to the new location at the top title area of the screen
        dummy.setName("fullScreen");
        titleLabel.setName("titleImage");
        parent.setTransitionOutAnimator(MorphTransition.create(1100).morph("fullScreen", "titleImage"));
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:33,代码来源:SocialChat.java

示例12: start

import com.codename1.ui.Form; //导入方法依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Clock Demo");
    AnalogClock clock = new AnalogClock();
    hi.setLayout(new BorderLayout());
    hi.addComponent(BorderLayout.CENTER, clock);
    clock.start();
    
    hi.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:14,代码来源:ClockDemo.java

示例13: showLoginForm

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void showLoginForm() {
    Form login = new Form("Login");
    BorderLayout bl = new BorderLayout();
    bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
    ComponentGroup loginDetails = new ComponentGroup();
    
    TextField displayName = new TextField();
    displayName.setHint("Display Name");
    loginDetails.addComponent(displayName);

    final TextField email = new TextField();
    email.setHint("E-Mail");
    loginDetails.addComponent(email);

    Button send = new Button("Send Verification");
    loginDetails.addComponent(send);
    
    send.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onSendAction(email);
        }
    });
    
    login.setLayout(bl);
    login.addComponent(BorderLayout.CENTER, loginDetails);
    login.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:28,代码来源:PhotoShare.java

示例14: showMeOnMap

import com.codename1.ui.Form; //导入方法依赖的package包/类
private void showMeOnMap() {
    Form map = new Form("Map");
    map.setLayout(new BorderLayout());
    map.setScrollable(false);
    final MapComponent mc = new MapComponent();

    putMeOnMap(mc);
    mc.zoomToLayers();

    map.addComponent(BorderLayout.CENTER, mc);
    map.getToolbar().addCommandToLeftBar(new MapsDemo.BackCommand());
    map.setBackCommand(new MapsDemo.BackCommand());
    map.show();

}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:16,代码来源:MapsDemo.java

示例15: play

import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
 * Start media playback implicitly setting the component to visible
 */
public void play() {
    if(nativePlayer && curentForm == null){
        curentForm = Display.getInstance().getCurrent();
        Form f = new Form();
        f.setLayout(new BorderLayout());
        f.addComponent(BorderLayout.CENTER, new MediaPlayer(this));
        f.show();
    }
    
    player.play();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:15,代码来源:GameCanvasImplementation.java


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