Java Code Examples for com.codename1.ui.Form#addAll()
The following examples show how to use
com.codename1.ui.Form#addAll() .
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: ArrayTests2768.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); Button b = new Button("Run Test"); SpanLabel result = new SpanLabel(); b.addActionListener(e->{ try { if (new MyTest().runTest()) { result.setText("Success"); } else { result.setText("Failed"); } } catch (Exception ex) { ex.printStackTrace(); result.setText("Failed: "+ex.getMessage()); } hi.revalidateWithAnimationSafety(); }); hi.addAll(b, result); hi.show(); }
Example 2
Source File: TextFieldCaretColorTest2780.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); hi.add(new Label("Hi World")); TextField tf1 = new TextField(); TextField tf2 = new TextField(); TextArea ta1 = new TextArea(); TextArea ta2 = new TextArea(); ta1.setRows(5); ta2.setRows(5); $(tf2, ta2).selectAllStyles() .setBgColor(0x0000ff) .setFgColor(0xffffff) .setBgTransparency(0xff) .setBackgroundType(Style.BACKGROUND_NONE); hi.addAll(tf1, tf2, ta1, ta2); hi.show(); }
Example 3
Source File: BindButtonStateTest.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); Button button1 = new Button("Button 1"); button1.setIconUIID("GrayIcon"); //button1.getIconStyleComponent().getStyle().setFgColor(0xff0000); FontImage.setIcon(button1, FontImage.MATERIAL_INBOX, -1); Button button2 = new Button("Button 2"); button2.bindStateTo(button1); hi.add(new Label("Hi World")); hi.addAll(button1, button2); hi.show(); }
Example 4
Source File: ImageGalleryMultiCrashIOS2926.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); Button btn = new Button("Open gallery"); SpanLabel log = new SpanLabel(""); hi.addAll(btn, log); hi.show(); btn.addActionListener(l -> { // Start content "BasePageForm-InnerBoxImages" CN.openGallery(new ActionListener() { public void actionPerformed(ActionEvent ev) { if (ev != null && ev.getSource() != null && ((String[]) ev.getSource()).length > 0) { String[] filesPaths = (String[]) ev.getSource(); String debug = "Original file paths taken from Gallery:"; for (String str : filesPaths) { debug += "\n" + str; Log.p(debug, Log.DEBUG); } log.setText(debug); hi.revalidate(); } } }, CN.GALLERY_IMAGE_MULTI); }); }
Example 5
Source File: TestTextComponentPassword2976.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start() { if(current != null){ current.show(); return; } TextModeLayout tl = new TextModeLayout(2, 1); Form f = new Form("Pixel Perfect", tl); TextComponent user = new TextComponent(); TextComponentPassword pass = new TextComponentPassword(); f.addAll(user, pass); f.show(); }
Example 6
Source File: SpanLabelTest2980.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start() { if(current != null){ current.show(); return; } Layout lay = new FlowLayout(); //Layout lay = BoxLayout.y(); Form hi = new Form("Gallery Test", lay); hi.add(new SpanLabel("Tap the following button to open the gallery. You should be able to select multiple images and videos.")); Button btn = new Button("Run Test"); SpanLabel files = new SpanLabel(); SpanLabel result = new SpanLabel(); btn.addActionListener(l -> { try { SpanLabelTests2980 test = new SpanLabelTests2980(); test.runTest(); result.setText("Test Passed"); } catch (Throwable t) { result.setText("Failed: "+t.getMessage()); } hi.revalidateWithAnimationSafety(); }); hi.addAll(btn, files, result); hi.show(); }
Example 7
Source File: LeadComponentDropListenerSample.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", new GridLayout(1, 2)); hi.setScrollable(false); Container draggable = new Container(new FlowLayout()); Label lead = new Label("Draggable"); draggable.add(lead); draggable.setLeadComponent(lead); draggable.getStyle().setBorder(Border.createLineBorder(1, 0xff0000)); draggable.setDraggable(true); lead.addDropListener(evt->{ System.out.println("Dropped"); }); Container dropTarget = new Container(new FlowLayout()) { @Override public void paint(Graphics g) { super.paint(g); g.setColor(0x0); g.setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL)); g.drawString("Drop Target", 0, 0); } }; dropTarget.getStyle().setBorder(Border.createLineBorder(1, 0x00ff00)); dropTarget.setDropTarget(true); dropTarget.add(new Label("DropTarget")); hi.addAll(draggable, dropTarget); hi.show(); }
Example 8
Source File: CSSVariablesSample.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); Container cnt1 = new Container(BoxLayout.y(), "Cnt1"); Container cnt2 = new Container(BoxLayout.y(), "Cnt2"); cnt1.add(new SpanLabel("Pink Container using CSS variable")); cnt2.add(new SpanLabel("Green Container because CSS variable not defined")); hi.addAll(cnt1, cnt2); hi.show(); }
Example 9
Source File: SimpleDateFormatTest.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public void start() { if(current != null){ current.show(); return; } final Form hi = new Form("Hi World", BoxLayout.y()); TextField dateStringIn = new TextField(); TextField dateFormat = new TextField(); Label shortMonth = new Label(); Label longMonth = new Label(); Label shortDate = new Label(); Label longDate = new Label(); Container result = new Container(BoxLayout.y()); Button parse = new Button("Parse Date"); Container resultWrapper = new Container(BoxLayout.y()); parse.addActionListener(evt->{ try { SimpleDateFormat inputFormat = new SimpleDateFormat(dateFormat.getText()); Date dt = inputFormat.parse(dateStringIn.getText()); SimpleDateFormat shortMonthFormat = new SimpleDateFormat("MMM"); shortMonth.setText(shortMonthFormat.format(dt)); SimpleDateFormat longMonthFormat = new SimpleDateFormat("MMMM"); longMonth.setText(longMonthFormat.format(dt)); longDate.setText(L10NManager.getInstance().formatDateLongStyle(dt)); shortDate.setText(L10NManager.getInstance().formatDateShortStyle(dt)); resultWrapper.removeAll(); resultWrapper.add(result); hi.revalidateWithAnimationSafety(); } catch (ParseException ex) { Log.e(ex); ToastBar.showErrorMessage("Parse failed: "+ex.getMessage()); } }); result.addAll( new Label("Short month name:"), shortMonth, new Label("Long month name:"), longMonth, new Label("Short Date:"), shortDate, new Label("Long Date:"), longDate ); hi.addAll( new Label("Date:"), dateStringIn, new Label("Date Format:"), dateFormat, parse, resultWrapper ); hi.show(); }
Example 10
Source File: UIFragmentSample.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private void testUIFragment() { Form f = new Form("Test Fragments", BoxLayout.y()); TextArea ta = new TextArea(); ta.setMaxSize(5000); String[] examples = new String[]{ "<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>", "{centerAbs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{cs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ca:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerScale:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ctb:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerTotalBelow:$button1, south:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{x:[$button2, $button3, $button4]}}", "{s:$button1, c:{y:[$button2, $button3, $button4]}}", "{s:$button1, c:{yBottomLast:[$button2, $button3, $button4]}}", "{s:$button1, c:{ybl:[$button2, $button3, $button4]}}" }; ComboBox cb = new ComboBox(examples); cb.addActionListener(e->{ ta.setText(examples[cb.getSelectedIndex()]); }); ta.setText("<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>"); Button b = new Button("Compile"); b.addActionListener(e->{ Form f2 = new Form("Result", new BorderLayout()); f2.setToolbar(new Toolbar()); f2.setTitle("Result"); f2.setBackCommand("Back", null, evt->{ f.showBack(); }); f2.getToolbar().addCommandToLeftBar("Back", null, evt->{ f.showBack(); }); Button b1 = new Button("Button 1"); Button b2 = new Button("Button 2"); Button b3 = new Button("Button 3"); Button b4 = new Button("Button 4"); $(b1, b2, b3, b4).selectAllStyles().setBorder(RoundRectBorder.create().cornerRadius(2)).setBgColor(0x003399).setBgTransparency(0xff); UIFragment frag; if (ta.getText().charAt(0) == '<') { frag = UIFragment.parseXML(ta.getText()); } else { System.out.println("Parsing "+ta.getText()); frag = UIFragment.parseJSON(ta.getText()); } f2.add(BorderLayout.CENTER,frag .set("button1", b1) .set("button2", b2) .set("button3", b3) .set("button4", b4) .getView() ); f2.show(); }); ta.setRows(5); f.addAll(cb, ta, b); f.show(); }
Example 11
Source File: InfiniteProgressWithMessage.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); Button showProgress = new Button("Show InfiniteProgress"); showProgress.addActionListener(e->{ callSerially(()->{ Dialog dlg = new Dialog(); dlg.setDialogUIID("Container"); dlg.setTintColor(0x0); dlg.setLayout(new BorderLayout()); SpanLabel message = new SpanLabel("This is a progress message we wish to show"); $("*", message).setFgColor(0xffffff); dlg.add(BorderLayout.CENTER, BoxLayout.encloseYCenter(FlowLayout.encloseCenter(new InfiniteProgress()), FlowLayout.encloseCenter(message))); dlg.setTransitionInAnimator(CommonTransitions.createEmpty()); dlg.setTransitionOutAnimator(CommonTransitions.createEmpty()); dlg.showPacked(BorderLayout.CENTER, false); //dlg.revalidateWithAnimationSafety(); invokeAndBlock(()->{ Util.sleep(5000); }); dlg.dispose(); }); }); Button showToastProgress = new Button("Show Toast Progress"); showToastProgress.addActionListener(e->{ callSerially(()->{ Status status = ToastBar.getInstance().createStatus(); status.setMessage("This is a progress message we wish to show"); status.setShowProgressIndicator(true); status.show(); invokeAndBlock(()->{ Util.sleep(5000); }); status.clear(); }); }); hi.addAll(showProgress, showToastProgress); hi.show(); }
Example 12
Source File: FingerprintScannerSample.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World", BoxLayout.y()); TextField keyName = new TextField(); TextField keyValue = new TextField(); Button addItem = new Button("Add Item"); Button getItem = new Button("Get Item"); Button deleteItem = new Button("Delete Item"); Button checkAvailable = new Button("Check Available"); checkAvailable.addActionListener(evt->{ Container cnt = BoxLayout.encloseY( new Label("TouchID: "+Fingerprint.isTouchIDAvailable()), new Label("FaceID: "+Fingerprint.isFaceIDAvailable()) ); Dialog.show("Capabilities", cnt, new Command("OK")); }); addItem.addActionListener(evt->{ if (!Fingerprint.isAvailable()) { ToastBar.showErrorMessage("Fingerprint not avaiable on this platform"); return; } Fingerprint.addPassword("Adding secure item to keystore", keyName.getText(), keyValue.getText()).onResult((res, err)->{ if (err != null) { Log.e(err); ToastBar.showErrorMessage(err.getMessage()); } else { ToastBar.showInfoMessage("Result: "+res); } }); }); getItem.addActionListener(evt->{ Fingerprint.getPassword("Getting secure item", keyName.getText()).onResult((res, err)->{ if (err != null) { Log.e(err); ToastBar.showErrorMessage(err.getMessage()); } else { keyValue.setText(res); hi.revalidateWithAnimationSafety(); } }); }); deleteItem.addActionListener(evt->{ Fingerprint.deletePassword("Getting secure item", keyName.getText()).onResult((res, err)->{ if (err != null) { Log.e(err); ToastBar.showErrorMessage(err.getMessage()); } else { keyValue.setText(""); hi.revalidateWithAnimationSafety(); } }); }); hi.addAll(new Label("Key:"), keyName, new Label("Value: "), keyValue, addItem, getItem, deleteItem, checkAvailable); hi.show(); }