Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // List3A →Print in cmd
- //Label , Button , ArrayList ( forEach )
- package com.mycompany.myapp;
- import static com.codename1.ui.CN.*;
- import com.codename1.ui.Display;
- import com.codename1.ui.Form;
- import com.codename1.ui.Dialog;
- import com.codename1.ui.Label;
- import com.codename1.ui.plaf.UIManager;
- import com.codename1.ui.util.Resources;
- import com.codename1.io.Log;
- import com.codename1.ui.Button;
- import com.codename1.ui.Container;
- import com.codename1.ui.Toolbar;
- import java.io.IOException;
- import com.codename1.ui.layouts.BoxLayout;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
- * of building native mobile applications using Java.
- */
- public class MyApplication {
- private Form current;
- private Resources theme;
- public void init(Object context) {
- theme = UIManager.initFirstTheme("/theme");
- // Enable Toolbar on all Forms by default
- Toolbar.setGlobalToolbar(true);
- // Pro only feature
- // Log.bindCrashProtection(true);
- }
- public void start() {
- if(current != null){
- current.show();
- return;
- }
- Form hi = new Form("Liste des personnes ", BoxLayout.y());
- Personne p1=new Personne("sana", "ben",
- Personne p2=new Personne("onsa", "ben",
- Personne p3=new Personne("sinda", "ben",
- List<Personne> lis=new ArrayList();
- lis.add(p1);
- lis.add(p2);
- lis.add(p3);
- for(Personne p:lis)
- hi.add(addItem(p));
- // hi.add(addItem(p1));
- // hi.add(addItem(p2));
- // hi.add(addItem(p3));
- hi.show();
- }
- public Container addItem(Personne p)
- {
- Label lbnom=new Label(p.getNom());
- Button btn=new Button(p.getMail());
- Label lbimg=new Label(theme.getImage(p.getNomimg()));
- Container cnt1=new Container(BoxLayout.y());
- cnt1.add(lbnom);
- cnt1.add(btn);
- Container cnt2=new Container(BoxLayout.x());
- cnt2.add(cnt1);
- cnt2.add(lbimg);
- btn.addActionListener(l->{
- System.out.println(p);
- });
- cnt2.setLeadComponent(btn);
- return cnt2;
- }
- public void stop() {
- current = getCurrentForm();
- if(current instanceof Dialog) {
- ((Dialog)current).dispose();
- current = getCurrentForm();
- }
- }
- public void destroy() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment