Java Code Examples for com.codename1.ui.Button#setUIID()
The following examples show how to use
com.codename1.ui.Button#setUIID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhotoShare.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
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; }
Example 2
Source File: Tree.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * 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.getAllStyles(), depth); return cmp; }
Example 3
Source File: SpanButton.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * 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.setGrowByContent(true); text.setEditable(false); text.setFocusable(false); text.setActAsLabel(true); setFocusable(true); removeBackground(text.getUnselectedStyle()); removeBackground(text.getSelectedStyle()); removeBackground(text.getPressedStyle()); removeBackground(text.getDisabledStyle()); actualButton = new Button(); actualButton.setUIID("icon"); addComponent(BorderLayout.WEST, actualButton); Container center = BoxLayout.encloseYCenter(text); center.getStyle().setMargin(0, 0, 0, 0); center.getStyle().setPadding(0, 0, 0, 0); addComponent(BorderLayout.CENTER, center); setLeadComponent(actualButton); updateGap(); }
Example 4
Source File: SocialChat.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
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(); }
Example 5
Source File: Poker.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
/** * A blocking method that creates the card deal animation and binds the drop logic when cards are dropped on the deck */ private void dealCard(Component deck, final Container destination, Image cardImage, Card currentCard) { final Button card = new Button(); card.setUIID("Label"); card.setIcon(cardImage); // Components are normally placed by layout managers so setX/Y/Width/Height shouldn't be invoked. However, // in this case we want the layout animation to deal from a specific location. Notice that we use absoluteX/Y // since the default X/Y are relative to their parent container. card.setX(deck.getAbsoluteX()); int deckAbsY = deck.getAbsoluteY(); if(destination.getY() > deckAbsY) { card.setY(deckAbsY - destination.getAbsoluteY()); } else { card.setY(deckAbsY); } card.setWidth(deck.getWidth()); card.setHeight(deck.getHeight()); destination.addComponent(card); // we save the model data directly into the component so we don't need to keep track of it. Later when we // need to check the card type a user touched we can just use getClientProperty card.putClientProperty("card", currentCard); destination.getParent().animateHierarchyAndWait(400); card.setDraggable(true); // when the user drops a card on a drop target (currently only the deck) we remove it and animate it out card.addDropListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); card.getParent().removeComponent(card); destination.animateLayout(300); } }); }
Example 6
Source File: KitchenSink.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
private Button createDemo(Demo d) { Button btn = new Button(d.getDisplayName(), d.getDemoIcon()); btn.setUIID("DemoButton"); initDemoButtonMargin(btn.getUnselectedStyle()); initDemoButtonMargin(btn.getSelectedStyle()); initDemoButtonMargin(btn.getPressedStyle()); initDemoButtonMargin(btn.getDisabledStyle()); btn.setTextPosition(Button.TOP); return btn; }
Example 7
Source File: Login.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public Login(Form f) { super("Login Form"); this.main = f; setLayout(new LayeredLayout()); Button login = new Button(FBDemo.getTheme().getImage("SignInFacebook.png_veryHigh.png")); login.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { signIn(main); } }); login.setUIID("CenterLabel"); addComponent(login); }
Example 8
Source File: CameraKitPickerTest7.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void showAnotherForm(){ Form form = new Form(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE)); form.setScrollable(false); Container container = new Container(BoxLayout.y()); container.add(new Label("Test", "heading5")); container.add(new Label("", "newLine")); container.add(new Label("", "newLine")); final Picker fromDate = new Picker(); fromDate.setType(Display.PICKER_TYPE_DATE); container.add(new Label("From Date", "heading7")); container.add(fromDate); container.add(new Label("", "newLine")); final Picker toDate = new Picker(); toDate.setType(Display.PICKER_TYPE_DATE); container.add(new Label("To Date", "heading7")); container.add(toDate); Button nextBtn = new Button("Proceed"); nextBtn.setUIID("loginBtn"); nextBtn.addActionListener((ev) -> { DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); String fromDateStr = dateFormat.format(fromDate.getDate()); String toDateStr = dateFormat.format(toDate.getDate()); }); container.add(new Label("", "newLine")); container.add(new Label("", "newLine")); container.add(nextBtn); form.add(BorderLayout.CENTER, container); form.show(); }
Example 9
Source File: Flickr.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
/** * This method builds a UI Entry dynamically from a data Map object. */ private static Component createEntry(Map data, final int index) { final Container cnt = new Container(new BorderLayout()); cnt.setUIID("MultiButton"); Button icon = new Button(); icon.setUIID("Label"); //take the time and use it as the identifier of the image String time = (String) data.get("date_taken"); String link = (String) ((Map) data.get("media")).get("m"); EncodedImage im = (EncodedImage) res.getImage("flickr.png"); final URLImage image = URLImage.createToStorage(im, time, link, null); icon.setIcon(image); icon.setName("ImageButton" + index); icon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Dialog d = new Dialog(); //d.setDialogUIID("Container"); d.setLayout(new BorderLayout()); Label l = new Label(image); l.setUIID("ImagePop"); d.add(BorderLayout.CENTER, l); d.setDisposeWhenPointerOutOfBounds(true); d.setTransitionInAnimator(new BubbleTransition(300, "ImageButton" + index)); d.setTransitionOutAnimator(new BubbleTransition(300, "ImageButton" + index)); d.show(); } }); cnt.addComponent(BorderLayout.WEST, icon); Container center = new Container(new BorderLayout()); Label des = new Label((String) data.get("title")); des.setUIID("MultiLine1"); center.addComponent(BorderLayout.NORTH, des); Label author = new Label((String) data.get("author")); author.setUIID("MultiLine2"); center.addComponent(BorderLayout.SOUTH, author); cnt.addComponent(BorderLayout.CENTER, center); return cnt; }
Example 10
Source File: SignatureComponent.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
/** * Creates a new signature component. */ public SignatureComponent() { setLayout(new BorderLayout()); xFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE); lead = new Button() { @Override protected void paintBackground(Graphics g) { super.paintBackground(g); g.setColor(0x666666); Style s = getStyle(); g.drawRect( getX()+s.getPaddingLeftNoRTL(), getY()+s.getPaddingTop(), getWidth()-s.getPaddingRightNoRTL()-s.getPaddingLeftNoRTL(), getHeight()-s.getPaddingBottom() - s.getPaddingTop() ); g.setFont(xFont); g.drawString("X", getX() + getStyle().getPaddingLeftNoRTL() + Display.getInstance().convertToPixels(3, true), getY() + getHeight() / 2); } }; lead.setText(localize("SignatureComponent.LeadText","Press to sign")); lead.setUIID("SignatureButton"); lead.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { final Dialog dialog = new Dialog(localize("SignatureComponent.DialogTitle", "Sign Here")); final SignatureDialogBody sigBody = new SignatureDialogBody() { @Override protected void onCancel() { super.onCancel(); dialog.dispose(); } }; sigBody.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent sigDoneEvent) { dialog.dispose(); setSignatureImage(sigBody.getValue()); fireActionEvent(); } }); dialog.setLayout(new BorderLayout()); dialog.addComponent(BorderLayout.CENTER, sigBody); dialog.setScrollable(false); dialog.setFocusable(false); dialog.show(); } }); addComponent(BorderLayout.CENTER, lead); }