Пример #1
0
  protected void execute(final Form f) {
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    f.setScrollable(false);
    list = new List(RENDERED_CONTENT);
    list.setFixedSelection(List.FIXED_NONE_CYCLIC);
    list.setSmoothScrolling(true);
    list.getStyle().setBgTransparency(0);
    renderers = new ListCellRenderer[RENDERED_CONTENT.length];
    renderers[0] = new AlternateImageRenderer();
    renderers[1] = new WidgetRenderer();
    renderers[2] = new AlternateColorRenderer();
    renderers[3] = new DefaultListCellRenderer();
    renderers[4] = new FishEyeRenderer();
    list.setListCellRenderer(renderers[0]);
    list.addActionListener(this);

    Label l = new Label("Press \"Select\" to update:");
    l.getStyle().setBgTransparency(100);
    f.addComponent(l);
    f.addComponent(list);
    l = new Label("Try Applying Renderer To Menu");
    l.getStyle().setBgTransparency(100);
    f.addComponent(l);
    f.addCommand(
        new Command("Set To Menu") {

          public void actionPerformed(ActionEvent ev) {
            f.setMenuCellRenderer(list.getRenderer());
          }
        });
  }
  public Form getSupportMe() {
    if (frmSupportMe == null) {
      // ---------------------------------------------
      // Form f = ...
      frmSupportMe = new Form("Support Me");
      frmSupportMe.setLayout(new BorderLayout());

      Image bimage = null;
      try {
        bimage = Image.createImage("/images/metaLabSmall.png");
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      Label bottomText = new Label(bimage);
      bottomText.setAlignment(Component.CENTER);
      bottomText.setText("Our Logo");
      bottomText.setTextPosition(Component.BOTTOM);

      Container buttonBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
      buttonBar.addComponent(new Button("Add"));
      buttonBar.addComponent(new Button("Remove"));
      buttonBar.addComponent(new Button("Edit"));
      buttonBar.addComponent(new Button("Send"));
      buttonBar.addComponent(new Button("Exit"));

      frmSupportMe.addComponent(BorderLayout.CENTER, bottomText);
      frmSupportMe.addComponent(BorderLayout.SOUTH, buttonBar);
      frmSupportMe.addCommand(mBackCommand);
      frmSupportMe.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSupportMe;
  }
Пример #3
0
  public MainMidlet() {
    // constructor: where all the variables initialisations are made
    // for Form 1
    box = new BoxLayout(BoxLayout.Y_AXIS);
    form1 = new Form(formLbl);
    form1.setLayout(box);
    text1 = new TextField("", TextField.NUMERIC);
    text2 = new TextField("", TextField.NUMERIC);
    text3 = new TextField("", TextField.NUMERIC);
    labl1 = new Label(lbl1);
    labl2 = new Label(lbl2);
    // contain = new Container();
    // contain.addComponent(labl1,text1);
    labl3 = new Label("");
    cmd1 = new com.sun.lwuit.Command(cmd1String);
    cmd2 = new com.sun.lwuit.Command(cmd2String);

    // ===========================
    form1.addComponent(labl1);
    form1.addComponent(text1);
    form1.addComponent(labl2);
    form1.addComponent(text2);
    form1.addCommand(cmd1);
    form1.addCommand(cmd2);
    // form1.addCommandListener(this);

  }
  public Form getSurveys() {
    if (frmSurveys == null) {
      frmSurveys = new Form("Surveys");
      Label sLabel = new Label("Surveys On Board");
      frmSurveys.addComponent(sLabel);

      frmSurveys.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      RadioButton rb;
      ButtonGroup group = new ButtonGroup();

      rb = new RadioButton("Grilled chicken");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Filet mignon");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Mahi mahi");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Chili");
      group.add(rb);
      frmSurveys.addComponent(rb);

      CheckBox cb;

      cb = new CheckBox("Guacamole");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Tabasco sauce");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Mango salsa");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Mayonnaise");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Whipped cream");
      frmSurveys.addComponent(cb);

      frmSurveys.addCommand(mBackCommand);
      frmSurveys.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSurveys;
  }
Пример #5
0
  public NewGuideView(TouristMidlet midlet) {
    super(midlet);
    setTitle("Buy guide");
    setLayout(new BorderLayout());
    getStyle().setBgColor(Visual.BACKGROUND_COLOR);

    loadingForm = new Form("Buy guide");
    loadingForm.setLayout(new BorderLayout());
    loadingComp = new LoadingComponent(this);
    loadingForm.addComponent(BorderLayout.CENTER, loadingComp);

    /* See the flow of In-App Purchasing at:
     * http://www.developer.nokia.com/Resources/Library/Java/#!developers-guides/in-app-purchase.html */
    try {
      manager = IAPClientPaymentManager.getIAPClientPaymentManager();
      IAPClientPaymentManager.setIAPClientPaymentListener(this);
    } catch (Exception e) {
      Util.showAlert(e.getClass().getName(), "Could not initialize In-App Purchase manager");
    }

    newGuideList = new NewGuideList(this);
    addComponent(BorderLayout.CENTER, newGuideList);

    loginButton = new Button("Login to see past purchases");
    loginButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            loadAccountAndGuides();
          }
        });
    addCommands();

    revalidate();
  }
  public Form getAboutUs() {
    final Form f = new Form("Event counting");
    if (frmAboutUs == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      final Button pushButton = new Button("Tap me!");
      final Label countLabel = new Label(" ");
      pushButton.addActionListener(
          new ActionListener() {
            private int c = 0;

            public void actionPerformed(ActionEvent ae) {
              c++;
              countLabel.setText(Integer.toString(c));
              f.layoutContainer();
              pushButton.setText("Tapped " + Integer.toString(c) + " times");
              // System.out.println(Integer.toString(c));
            }
          });
      f.addComponent(pushButton);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
  /*
   public PIMBrowser getPimToDo() {
      if (pimToDo == null) {
          // write pre-init user code here
          pimToDo = new PIMBrowser(getDisplay(), PIM.TODO_LIST);
          pimToDo.setTitle("To Do List");
          pimToDo.addCommand(PIMBrowser.SELECT_PIM_ITEM);
          pimToDo.addCommand(getBackCommand5());
          pimToDo.setCommandListener(this);
          // write post-init user code here
      }
      return pimToDo;
  }
  */
  public Form fullgetToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      toDoList = new List();
      pim = PIM.getInstance();
      f.addComponent(toDoList);

      final TextArea searchField = TextField.create();
      f.addComponent(searchField);

      Button searchButton = new Button("Search");
      searchButton.setPreferredW(f.getWidth() / 2 - 5);
      searchButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              populateToDoList(searchField.getText());
            }
          });
      Button clearButton = new Button("Clear");
      clearButton.setPreferredW(f.getWidth() / 2 - 5);
      clearButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              searchField.setText("");
              populateToDoList("");
            }
          });
      Container buttonContainer = new Container();
      buttonContainer.setLayout(new BorderLayout());
      buttonContainer.addComponent(BorderLayout.WEST, searchButton);
      buttonContainer.addComponent(BorderLayout.EAST, clearButton);
      f.addComponent(buttonContainer);

      populateToDoList(searchField.getText());

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getAboutYou() {
    Form f = new Form("...placeholder ...");
    if (frmAboutYou == null) {
      f.addComponent(new Label("Choose Back to return to the home screen."));

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
  public Form getResources() {
    if (frmResources == null) {
      frmResources = new Form("Resources");

      List list = new List();
      list.addItem("uno");
      list.addItem("due");
      list.addItem("tre");
      list.addItem("quattro");
      list.addItem("cinque");
      list.addItem("sei");
      frmResources.addComponent(list);

      ComboBox comboBox = new ComboBox(list.getModel());
      frmResources.addComponent(comboBox);
      frmResources.addCommand(mBackCommand);
      frmResources.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmResources;
  }
  public Form getMessages() {
    if (frmMessages == null) {
      // ---------------------------------------------------
      frmMessages = new Form("Messages");
      TextArea area = new TextArea("Peppino");
      frmMessages.addComponent(area);

      TextArea big =
          new TextArea(
              "On February 24, 1815, the lookout at "
                  + "Notre-Dame de la Garde signalled the arrival of the three-master "
                  + "Pharaon, coming from Smyrna, Trieste and Naples.",
              5,
              20);
      frmMessages.addComponent(big);
      frmMessages.addCommand(mBackCommand);
      frmMessages.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      // ---------------------------------------

    }
    return frmMessages;
  }
  public Form getToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      Label sLabel = new Label("To Do List appears here");
      f.addComponent(sLabel);

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getCalendar() {
    Form f = new Form("Calendar");

    if (frmCalendar == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      Calendar cal = new Calendar();
      f.addComponent(cal);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  @Test
  public void testTextFieldReturnsBackToRSKAfterEditWithoutTextEditor()
      throws InterruptedException {
    final Form f = new Form();
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    Command back = new Command("back");
    f.setBackCommand(back);

    TextField field = new TextField();
    f.addComponent(field);
    f.show();
    waitEdt();
    f.setFocused(field);
    MenuBar menubar = f.getMenuBar();
    Button[] softButtons = menubar.getSoftButtons();
    softButtons[0].released();
    waitEdt();
    softButtons[0].released();
    waitEdt();
    Command[] cmds = menubar.getSoftCommands();
    assertEquals(back, cmds[2]);
  }
  public Form getTorch() {
    Form f = new Form("Torch");
    if (frmTorch == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      Label sLabel = new Label("Torch");
      f.addComponent(sLabel);
      /*
                  UIManager uim = UIManager.getInstance();
                  Hashtable ht = new Hashtable();
                  ht.put("sel#" + Style.BG_COLOR, "d0d0ed");
                  ht.put(Style.BG_COLOR, "ffffff");
                  ht.put(Style.FG_COLOR, "000056");
                  uim.setThemeProps(ht);
      */

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  private void createUI() {
    // Set up screen for transitions.
    mAwayForm = new Form("...placeholder ...");
    mAwayForm.addComponent(new Label("Choose Back to return to the home screen."));

    mBackCommand = new Command("Back");
    mAwayForm.addCommand(mBackCommand);
    mAwayForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.

    frmSurveys = getSurveys();
    frmChallenges = getChallenges();
    frmResources = getResources();
    frmMessages = getMessages();
    frmSupportMe = getSupportMe();
    frmAboutUs = getAboutUs();
    frmAboutYou = getAboutYou();
    frmCalendar = getCalendar();
    frmContacts = getContacts();
    frmToDoList = getToDoList();
    frmTorch = getTorch();

    // Set up main screen.
    mHomeForm = new Form("Today");
    mHomeForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

    btnChallengesFrm = new Button("Challenges");
    btnChallengesFrm.addActionListener(this);
    mHomeForm.addComponent(btnChallengesFrm);

    btnSurveysFrm = new Button("Surveys");
    btnSurveysFrm.addActionListener(this);
    mHomeForm.addComponent(btnSurveysFrm);

    btnResourceFrm = new Button("Resources");
    btnResourceFrm.addActionListener(this);
    mHomeForm.addComponent(btnResourceFrm);

    mCubeButton = new Button("Messages");
    mCubeButton.addActionListener(this);
    mHomeForm.addComponent(mCubeButton);

    btnSupportFrm = new Button("Support Me");
    btnSupportFrm.addActionListener(this);
    mHomeForm.addComponent(btnSupportFrm);

    btnContactsFrm = new Button("Contacts");
    btnContactsFrm.addActionListener(this);
    mHomeForm.addComponent(btnContactsFrm);

    btnCalendarFrm = new Button("Calendar");
    btnCalendarFrm.addActionListener(this);
    mHomeForm.addComponent(btnCalendarFrm);

    btnToDoFrm = new Button("To Do");
    btnToDoFrm.addActionListener(this);
    mHomeForm.addComponent(btnToDoFrm);

    mFilesButton = new Button("Files");
    mFilesButton.addActionListener(this);
    mHomeForm.addComponent(mFilesButton);

    btnAboutUs = new Button("About Us");
    btnAboutUs.addActionListener(this);
    mHomeForm.addComponent(btnAboutUs);

    btnAboutYou = new Button("About You");
    btnAboutYou.addActionListener(this);
    mHomeForm.addComponent(btnAboutYou);

    btnTorch = new Button("Torch");
    btnTorch.addActionListener(this);
    mHomeForm.addComponent(btnTorch);

    mExitCommand = new Command("Exit");
    mHomeForm.addCommand(mExitCommand);
    mHomeForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
  }
Пример #16
0
  public Form getForm() {

    if (loginForm != null) {
      titleLbl.setText("Login:"******"NoiseTube Account");
    loginPanel = new Container();
    loginPanel.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    titleLbl = new Label(" ");

    usernameLbl = new Label();
    usernameTxt = new TextField();
    usernameLbl.setText("Username:"******"Password:"******"Skip");
    loginCmd = new Command("Login");

    // buttonPanel = new Container();
    // buttonPanel.addComponent(loginBtn);
    // buttonPanel.getStyle().setMargin(2, 2, 2, 2);

    titleLbl.setText("Login:"******"Connexion error");
                titleLbl.setText("Connexion error");
              } catch (RecordStoreException e1) {
                titleLbl.setText("Error saving APIkey");
                log.error(e1, "Error saving APIkey");
              }
            } else if (skipCmd.equals(arg0.getCommand())) {
              MainMidlet.getInstance()
                  .getPreferences()
                  .setSavingMode(
                      Device.supportsSavingToFile() ? Preferences.SAVE_FILE : Preferences.SAVE_NO);
              midlet.showMeasureForm();
            } else midlet.notifyDestroyed();
          }
        });
    return loginForm;
  }
  public Form getChallenges() {
    Form f = new Form("Top Challenges");

    if (frmChallenges == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      class Node {
        Object[] children;
        String value;

        public Node(String value, Object[] children) {
          this.children = children;
          this.value = value;
        }

        public String toString() {
          return value;
        }
      }
      TreeModel model =
          new TreeModel() {
            Node[] sillyTree = {
              new Node(
                  "Energy Banner: 23 completed: 77 Rewards available",
                  new Node[] {
                    new Node(
                        "CHALLENGE: Get together a minimum of 5 friends or family, create a Banner with energy-saving awareness message, display in your community",
                        new Node[] {}),
                    new Node("REWARD: R15 Airtime (only 77 Rewards remaining)", new Node[] {}),
                    new Node(
                        "TO WIN: Send in a photo of you and your friends holding the banner in your community",
                        new Node[] {}),
                    new Node("CLOSES: 21 June 2013", new Node[] {}),
                  }),
              new Node("Well Watch", new Node[] {new Node("A", new Node[] {})}),
              new Node(
                  "Hear Me, My Friend",
                  new Node[] {
                    new Node("A", new Node[] {}),
                  }),
            };

            public Vector getChildren(Object parent) {
              Node n = (Node) parent;
              Object[] nodes;
              if (parent == null) {
                nodes = sillyTree;
              } else {
                nodes = n.children;
              }
              Vector v = new Vector();
              for (int iter = 0; iter < nodes.length; iter++) {
                v.addElement(nodes[iter]);
              }
              return v;
            }

            public boolean isLeaf(Object node) {
              Node n = (Node) node;
              return n.children == null || n.children.length == 0;
            }
          };

      f.setLayout(new BorderLayout());
      f.addComponent(BorderLayout.CENTER, new Tree(model));

      /*
      f.addComponent(area);

      TextArea big = new TextArea("Keep your community clean and win lots of STUFF");
      big.setGrowByContent(true);
      big.setEditable(false);
      f.addComponent(big);


      List list = new List();
        list.addItem("Street Clean Up");
        list.addItem("Drinking Water Clean-Up");
        list.addItem("Deadland Tidy");
        list.addItem("Tree Rescue");
        f.addComponent(list);

      f.addComponent(new Tree(list));
       */

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }