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

Java Dialog类代码示例

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

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



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

示例1: listenToMessages

import com.codename1.ui.Dialog; //导入依赖的package包/类
private void listenToMessages() {
    try {
        pb = new Pubnub(PUBNUB_PUB_KEY, PUBNUB_SUB_KEY);
        pb.subscribe(tokenPrefix + uniqueId, new Callback() {
            @Override
            public void successCallback(String channel, Object message, String timetoken) {
                if(message instanceof String) {
                    pendingAck.remove(channel);
                    return;
                }
                Message m = new Message((JSONObject)message);
                pb.publish(tokenPrefix + m.getSenderId(),  "ACK", new Callback() {});
                Display.getInstance().callSerially(() -> {
                    addMessage(m);
                    respond(m);
                });
            }
        });
    } catch(PubnubException err) {
        Log.e(err);
        Dialog.show("Error", "There was a communication error: " + err, "OK", null);
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:SocialChat.java


示例2: getComponentRegistry

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


示例3: refreshGrid

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


示例4: createDetailsButtonActionListener

import com.codename1.ui.Dialog; //导入依赖的package包/类
ActionListener createDetailsButtonActionListener(final long imageId) {
    return new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                InfiniteProgress ip = new InfiniteProgress();
                Dialog dlg = ip.showInifiniteBlocking();
                try {
                    String[] data = WebServiceProxy.getPhotoDetails(imageId);
                    String s = "";
                    for(String d : data) {
                        s += d;
                        s += "\n";
                    }
                    dlg.dispose();
                    Dialog.show("Data", s, "OK", null);
                } catch(IOException err) {
                    dlg.dispose();
                    Dialog.show("Error", "Error connecting to server", "OK", null);
                }
            }
        };
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:22,代码来源:PhotoShare.java


示例5: start

import com.codename1.ui.Dialog; //导入依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    placeholder = EncodedImage.createFromImage(Image.createImage(53, 81, 0), false);
    Form react = new Form("React Demo", new BorderLayout());
    react.add(BorderLayout.CENTER, new InfiniteContainer() {
        public Component[] fetchComponents(int index, int amount) {
            try {
                Collection data = (Collection)ConnectionRequest.fetchJSON(REQUEST_URL).get("movies");
                Component[] response = new Component[data.size()];
                int offset = 0;
                for(Object movie : data) {
                    response[offset] = createMovieEntry(Result.fromContent((Map)movie));
                    offset++;
                }
                return response;
            } catch(IOException err) {
                Dialog.show("Error", "Error during connection: " + err, "OK", null);
            }
            return null;
        }
    });
    react.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:27,代码来源:ReactDemo.java


示例6: showFacebookUser

import com.codename1.ui.Dialog; //导入依赖的package包/类
private void showFacebookUser(String token){
    ConnectionRequest req = new ConnectionRequest();
    req.setPost(false);
    req.setUrl("https://graph.facebook.com/v2.3/me");
    req.addArgumentNoEncoding("access_token", token);
    InfiniteProgress ip = new InfiniteProgress();
    Dialog d = ip.showInifiniteBlocking();
    NetworkManager.getInstance().addToQueueAndWait(req);
    byte[] data = req.getResponseData();
    JSONParser parser = new JSONParser();
    Map map = null;
    try {
        map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    String name = (String) map.get("name");
    d.dispose();
    Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), "https://graph.facebook.com/v2.3/me/picture?access_token=" + token);
    userForm.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:22,代码来源:SignIn.java


示例7: showGoogleUser

import com.codename1.ui.Dialog; //导入依赖的package包/类
private void showGoogleUser(String token){
    ConnectionRequest req = new ConnectionRequest();
    req.addRequestHeader("Authorization", "Bearer " + token);
    req.setUrl("https://www.googleapis.com/plus/v1/people/me");
    req.setPost(false);
    InfiniteProgress ip = new InfiniteProgress();
    Dialog d = ip.showInifiniteBlocking();
    NetworkManager.getInstance().addToQueueAndWait(req);
    d.dispose();
    byte[] data = req.getResponseData();
    JSONParser parser = new JSONParser();
    Map map = null;
    try {
        map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    String name = (String) map.get("displayName");
    Map im = (Map) map.get("image");
    String url = (String) im.get("url");
    Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), url);
    userForm.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:SignIn.java


示例8: share

import com.codename1.ui.Dialog; //导入依赖的package包/类
@Override
public void share(String text, String image, String mimeType, Rectangle sourceRect){
    if(image != null && image.length() > 0) {
        try {
            Image img = Image.createImage(image);
            if(img == null) {
                nativeInstance.socialShare(text, 0, sourceRect );
                return;
            }
            NativeImage n = (NativeImage)img.getImage();
            nativeInstance.socialShare(text, n.peer, sourceRect);
        } catch(IOException err) {
            err.printStackTrace();
            Dialog.show("Error", "Error loading image: " + image, "OK", null);
        }
    } else {
        nativeInstance.socialShare(text, 0, sourceRect);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:IOSImplementation.java


示例9: drawDialogCmp

import com.codename1.ui.Dialog; //导入依赖的package包/类
private void drawDialogCmp(Graphics g, Dialog dlg) {
    Painter p = dlg.getStyle().getBgPainter();
    dlg.getStyle().setBgPainter(null);
    g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
    g.translate(-getDialogParent(dlg).getX(), -getDialogParent(dlg).getY() + getDialogTitleHeight(dlg));
    getDialogParent(dlg).paintComponent(g, false);
    if(drawDialogMenu && dlg.getCommandCount() > 0) {
        Component menuBar = dlg.getSoftButton(0).getParent();
        if(menuBar != null) {
            g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
            menuBar.paintComponent(g, false);
        }
    }

    dlg.getStyle().setBgPainter(p);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:CommonTransitions.java


示例10: drawDialogCmp

import com.codename1.ui.Dialog; //导入依赖的package包/类
private void drawDialogCmp(Graphics g, Dialog dlg) {
    Painter p = dlg.getStyle().getBgPainter();
    dlg.getStyle().setBgPainter(null);
    g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
    g.translate(-getDialogParent(dlg).getX(), -getDialogParent(dlg).getY());
    getDialogParent(dlg).paintComponent(g, false);
    if (dlg.getCommandCount() > 0) {
        Component menuBar = dlg.getSoftButton(0).getParent();
        if (menuBar != null) {
            g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
            menuBar.paintComponent(g, false);
        }
    }

    dlg.getStyle().setBgPainter(p);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:BubbleTransition.java


示例11: showOn

import com.codename1.ui.Dialog; //导入依赖的package包/类
/**
 * Install the glass tutorial on a form and seamlessly dismiss it when no longer necessary
 * @param f the form
 */
public void showOn(Form f) {
    Painter oldPane = f.getGlassPane();
    f.setGlassPane(this);
    Dialog dummy = new Dialog() {
        public void keyReleased(int i) {
            dispose();
        }
    };
    int oldTint = f.getTintColor();
    f.setTintColor(0);
    
    dummy.getDialogStyle().setBgTransparency(0);
    dummy.setDisposeWhenPointerOutOfBounds(true);
    dummy.show(0, Display.getInstance().getDisplayHeight() - 2, 0, Display.getInstance().getDisplayWidth() - 2, true, true);
    
    f.setTintColor(oldTint);
    f.setGlassPane(oldPane);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:GlassTutorial.java


示例12: authenticate

import com.codename1.ui.Dialog; //导入依赖的package包/类
/**
 * This method preforms the actual authentication, this method is a blocking
 * method that will display the user the html authentication pages.
 *
 * @return the method if passes authentication will return the access token
 * or null if authentication failed.
 *
 * @throws IOException the method will throw an IOException if something
 * went wrong in the communication.
 * @deprecated use createAuthComponent or showAuthentication which work
 * asynchronously and adapt better to different platforms
 */
public String authenticate() {

    if (token == null) {
        login = new Dialog();
        boolean i = Dialog.isAutoAdjustDialogSize();
        Dialog.setAutoAdjustDialogSize(false);
        login.setLayout(new BorderLayout());
        login.setScrollable(false);

        Component html = createLoginComponent(null, null, null, null);
        login.addComponent(BorderLayout.CENTER, html);
        login.setScrollable(false);
        login.setDialogUIID("Container");
        login.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 300));
        login.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, false, 300));
        login.show(0, 0, 0, 0, false, true);
        Dialog.setAutoAdjustDialogSize(i);
    }

    return token;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:34,代码来源:Oauth2.java


示例13: showAuthentication

import com.codename1.ui.Dialog; //导入依赖的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: handleErrorResponseCode

import com.codename1.ui.Dialog; //导入依赖的package包/类
/**
 * Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)
 *
 * @param code the response code from the server
 * @param message the response message from the server
 */
protected void handleErrorResponseCode(int code, String message) {
    if(responseCodeListeners != null) {
        if(!isKilled()) {
            NetworkEvent n = new NetworkEvent(this, code, message);
            responseCodeListeners.fireActionEvent(n);
        }
        return;
    }
    if(failSilently) {
        failureErrorCode = code;
        return;
    }
    if(Display.isInitialized() && !Display.getInstance().isMinimized() &&
            Dialog.show("Error", code + ": " + message, "Retry", "Cancel")) {
        retry();
    } else {
        retrying = false;
        if(!isReadResponseForErrors()){
            killed = true;
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:29,代码来源:ConnectionRequest.java


示例15: getToastBarComponent

import com.codename1.ui.Dialog; //导入依赖的package包/类
private ToastBarComponent getToastBarComponent() {
    Form f = Display.getInstance().getCurrent();
    if (f != null && !(f instanceof Dialog)) {
        ToastBarComponent c = (ToastBarComponent)f.getClientProperty("ToastBarComponent");
        if (c == null || c.getParent() == null) {
            c = new ToastBarComponent();
            c.hidden = true;
            f.putClientProperty("ToastBarComponent", c);
            Container layered = f.getLayeredPane(this.getClass(), true);
            layered.setLayout(new BorderLayout());
            layered.addComponent(position==Component.TOP ? BorderLayout.NORTH : BorderLayout.SOUTH, c);
            updateStatus();
        }
        if(position == Component.BOTTOM && f.getInvisibleAreaUnderVKB() > 0) {
            Style s = c.getAllStyles();
            s.setMarginUnit(Style.UNIT_TYPE_PIXELS);
            s.setMarginBottom(f.getInvisibleAreaUnderVKB());
        }
        return c;
    }
    return null;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:ToastBar.java


示例16: start

import com.codename1.ui.Dialog; //导入依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    hi.show();
    
    if (System.currentTimeMillis() < 100) {
        QRScanner.scanQRCode(new ScanResult() {
            public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
                Dialog.show("Completed", contents, "OK", null);
            }

            public void scanCanceled() {
                Dialog.show("Cancelled", "Scan Cancelled", "OK", null);
            }

            public void scanError(int errorCode, String message) {
                Dialog.show("Error", message, "OK", null);
            }
        });
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:ComponentTest.java


示例17: captureAudio

import com.codename1.ui.Dialog; //导入依赖的package包/类
public void captureAudio(ActionListener response) {
    String p = FileSystemStorage.getInstance().getAppHomePath();
    if(!p.endsWith("/")) {
        p += "/";
    }
    try {
        final Media media = MediaManager.createMediaRecorder(p + "cn1TempAudioFile", MediaManager.getAvailableRecordingMimeTypes()[0]);
        media.play();

        boolean b = Dialog.show("Recording", "", "Save", "Cancel");
        final Dialog d = new Dialog("Recording");

        media.pause();
        media.cleanup();
        d.dispose();
        if(b) {
            response.actionPerformed(new ActionEvent(p + "cn1TempAudioFile"));
        } else {
            FileSystemStorage.getInstance().delete(p + "cn1TempAudioFile");
            response.actionPerformed(null);
        }
    } catch(IOException err) {
        err.printStackTrace();
        response.actionPerformed(null);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:IOSImplementation.java


示例18: share

import com.codename1.ui.Dialog; //导入依赖的package包/类
@Override
public void share(String text, String image, String mimeType){
    if(image != null && image.length() > 0) {
        try {
            Image img = Image.createImage(image);
            if(img == null) {
                nativeInstance.socialShare(text, 0);
                return;
            }
            NativeImage n = (NativeImage)img.getImage();
            nativeInstance.socialShare(text, n.peer);
        } catch(IOException err) {
            err.printStackTrace();
            Dialog.show("Error", "Error loading image: " + image, "OK", null);
        }
    } else {
        nativeInstance.socialShare(text, 0);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:IOSImplementation.java


示例19: authenticate

import com.codename1.ui.Dialog; //导入依赖的package包/类
/**
 * This method preforms the actual authentication, this method is a blocking
 * method that will display the user the html authentication pages.
 *
 * @return the method if passes authentication will return the access token
 * or null if authentication failed.
 *
 * @throws IOException the method will throw an IOException if something went
 * wrong in the communication.
 * @deprecated use createAuthComponent or showAuthentication which work asynchronously and adapt better
 * to different platforms
 */
public String authenticate() {

    if (token == null) {
        login = new Dialog();
        boolean i = Dialog.isAutoAdjustDialogSize();
        Dialog.setAutoAdjustDialogSize(false);
        login.setLayout(new BorderLayout());
        login.setScrollable(false);

        Component html = createLoginComponent(null, null, null, null);
        login.addComponent(BorderLayout.CENTER, html);
        login.setScrollable(false);
        login.setDialogUIID("Container");
        login.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 300));
        login.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, false, 300));
        login.show(0, 0, 0, 0, false, true);
        Dialog.setAutoAdjustDialogSize(i);
    }

    return token;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:Oauth2.java


示例20: showAuthentication

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java BatchSentenceResource类代码示例发布时间:2022-05-23
下一篇:
Java HttpClientDownloader类代码示例发布时间: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