コード例 #1
0
  /**
   * This method places all the components onto the panel.
   *
   * @param panel (a {@link JPanel} giving the the panel where to place components)
   */
  private void placeComponents(JPanel panel) {

    panel.removeAll();
    panel.setLayout(null);
    Font fontTitre = new Font("Courier", Font.BOLD, 20);

    //	Adding Labels
    JLabel addUserTitle = new JLabel();
    addUserTitle.setBounds(250, 30, 300, 100);
    addUserTitle.setFont(fontTitre);
    addUserTitle.setText("<html>Add a User</html>");
    panel.add(addUserTitle);

    // Adding Buttons
    returnUsersButton.addActionListener(this);
    panel.add(returnUsersButton);

    validateAddUserButton.addActionListener(this);
    panel.add(validateAddUserButton);

    // Adding Text Fields
    addUserNickname.addActionListener(this);
    addUserNickname.setBounds(250, 100, 200, 25);
    panel.add(addUserNickname);

    addUserPassword.addActionListener(this);
    addUserPassword.setBounds(250, 140, 200, 25);
    panel.add(addUserPassword);

    addUserEMail.addActionListener(this);
    addUserEMail.setBounds(250, 180, 200, 25);
    panel.add(addUserEMail);

    // Adding Roles List
    addUserRole.addItem("Simple User");
    addUserRole.addItem("Seller");
    addUserRole.addItem("Admin");
    addUserRole.setSelectedIndex(0);
    addUserRole.addActionListener(this);
    addUserRole.setBounds(250, 220, 200, 25);
    panel.add(addUserRole);

    // Adding Logo
    JLabel image = new JLabel(new ImageIcon("logo.png"));
    JPanel panelLogo = new JPanel();
    panelLogo.setBounds(5, 5, 150, 150);
    panelLogo.setLayout(new BorderLayout());
    panelLogo.add(image, BorderLayout.CENTER);
    panel.add(panelLogo);
  }
コード例 #2
0
  private AbstractComponent createButton(final Animation animation) {
    PlainContainer container = new PlainContainer();
    container.setLayout(new VerticalLayout());
    container.setXAlignment(0.5);

    PlainContainer center = new PlainContainer();
    center.setXAlignment(0.5);
    center.setYAlignment(0.5);
    center.setMinimumWidth(64);
    center.setMaximumWidth(64);
    center.setMinimumHeight(64);
    center.setMaximumHeight(64);

    ImagePose icon =
        Editor.instance.getStylesheet().resources.getPose("animation-" + animation.getTagName());
    ImageComponent img = new ImageComponent((icon == null) ? null : icon.getSurface());
    center.addChild(img);
    Button button = new Button(center);
    container.addChild(button);

    container.addChild(new Label(animation.getName()));

    button.addActionListener(
        new ActionListener() {
          @Override
          public void action() {
            AnimationTypePicker.this.hide();
            AnimationTypePicker.this.pick(animation);
          }
        });

    return container;
  }
コード例 #3
0
  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;
  }
コード例 #4
0
ファイル: AppletViewer.java プロジェクト: ronshapiro/j86
  /** Create the tag frame. */
  TextFrame(int x, int y, String title, String text) {
    setTitle(title);
    TextArea txt = new TextArea(20, 60);
    txt.setText(text);
    txt.setEditable(false);

    add("Center", txt);

    Panel p = new Panel();
    add("South", p);
    Button b = new Button(amh.getMessage("button.dismiss", "Dismiss"));
    p.add(b);

    class ActionEventListener implements ActionListener {
      public void actionPerformed(ActionEvent evt) {
        dispose();
      }
    }
    b.addActionListener(new ActionEventListener());

    pack();
    move(x, y);
    setVisible(true);

    WindowListener windowEventListener =
        new WindowAdapter() {

          public void windowClosing(WindowEvent evt) {
            dispose();
          }
        };

    addWindowListener(windowEventListener);
  }
コード例 #5
0
  private AbstractComponent createNinePatchButton(final NinePatch ninePatch) {
    PlainContainer container = new PlainContainer();

    container.setLayout(new VerticalLayout());
    container.setXAlignment(0.5f);

    ImageComponent img = new ImageComponent();
    if (ninePatch != null) {
      img.setImage(ninePatch.getThumbnail());
    }
    Button button = new Button(img);
    button.addActionListener(
        new ActionListener() {
          @Override
          public void action() {
            NinePatchPicker.this.hide();
            NinePatchPicker.this.pick(ninePatch);
          }
        });

    Label label = new Label(ninePatch == null ? "<none>" : ninePatch.getName());

    container.addChild(button);
    container.addChild(label);

    return container;
  }
コード例 #6
0
  /*
   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;
  }
コード例 #7
0
  public NinePatchPicker(Resources resources, NinePatch defaultNinePatch) {
    super("Pick a Nine Patch");
    this.resources = resources;
    this.defaultNinePatch = defaultNinePatch;

    this.clientArea.setLayout(new VerticalLayout());
    this.clientArea.setFill(true, false);

    PlainContainer container = new PlainContainer();
    container.setLayout(new VerticalLayout());
    VerticalScroll vs = new VerticalScroll(container);

    Component focus = this.createChoices(container);
    this.clientArea.addChild(vs);
    this.clientArea.addStyle("vScrolled");

    PlainContainer buttons = new PlainContainer();
    buttons.addStyle("buttonBar");
    buttons.setLayout(new HorizontalLayout());
    buttons.setXAlignment(0.5f);

    Button cancel = new Button("Cancel");
    cancel.addActionListener(
        new ActionListener() {

          @Override
          public void action() {
            NinePatchPicker.this.hide();
          }
        });
    buttons.addChild(cancel);
    this.clientArea.addChild(buttons);

    if (focus != null) {
      focus.focus();
    }
  }
コード例 #8
0
ファイル: Calendar.java プロジェクト: mehulsbhatt/CodenameOne
  /**
   * Creates a new instance of Calendar set to the given date based on time since epoch (the
   * java.util.Date convention)
   *
   * @param time time since epoch
   * @param tmz a reference timezone
   */
  public Calendar(long time, TimeZone tmz) {
    super(new BorderLayout());
    this.tmz = tmz;
    setUIID("Calendar");
    mv = new MonthView(time);

    Image leftArrow = UIManager.getInstance().getThemeImageConstant("calendarLeftImage");
    if (leftArrow != null) {
      Image rightArrow = UIManager.getInstance().getThemeImageConstant("calendarRightImage");
      final Button left = new Button(leftArrow);
      final Button right = new Button(rightArrow);
      ActionListener progress =
          new ActionListener() {
            private boolean lock = false;

            public void actionPerformed(ActionEvent evt) {
              if (lock) {
                return;
              }
              lock = true;
              int month = mv.getMonth();
              int year = mv.getYear();
              if (evt.getSource() == left) {
                month--;
                if (month < java.util.Calendar.JANUARY) {
                  month = java.util.Calendar.DECEMBER;
                  year--;
                }
              } else {
                month++;
                if (month > java.util.Calendar.DECEMBER) {
                  month = java.util.Calendar.JANUARY;
                  year++;
                }
              }
              boolean tran = UIManager.getInstance().isThemeConstant("calTransitionBool", true);
              if (tran) {
                Transition cm;
                if (UIManager.getInstance().isThemeConstant("calTransitionVertBool", false)) {
                  cm =
                      CommonTransitions.createSlide(
                          CommonTransitions.SLIDE_VERTICAL, evt.getSource() == left, 300);
                } else {
                  cm =
                      CommonTransitions.createSlide(
                          CommonTransitions.SLIDE_HORIZONTAL, evt.getSource() == left, 300);
                }
                MonthView newMv = new MonthView(mv.currentDay);
                newMv.setMonth(year, month);
                replaceAndWait(mv, newMv, cm);
                mv = newMv;
                newMv.fireActionEvent();
              } else {
                mv.setMonth(year, month);
                componentChanged();
              }
              dateLabel.setText(getLocalizedMonth(month) + " " + year);
              lock = false;
            }
          };
      left.addActionListener(progress);
      right.addActionListener(progress);
      left.setUIID("CalendarLeft");
      right.setUIID("CalendarRight");

      Container dateCnt = new Container(new BorderLayout());
      dateCnt.setUIID("CalendarDate");
      dateLabel = new Label();
      dateLabel.setUIID("CalendarDateLabel");
      dateLabel.setText(getLocalizedMonth(mv.getMonth()) + " " + mv.getYear());

      dateCnt.addComponent(BorderLayout.CENTER, dateLabel);
      dateCnt.addComponent(BorderLayout.EAST, right);
      dateCnt.addComponent(BorderLayout.WEST, left);

      addComponent(BorderLayout.NORTH, dateCnt);
    } else {
      month = new ComboBox();
      year = new ComboBox();
      Vector months = new Vector();
      for (int i = 0; i < MONTHS.length; i++) {
        months.addElement("" + getLocalizedMonth(i));
      }
      ListModel monthsModel = new DefaultListModel(months);
      int selected = months.indexOf(getLocalizedMonth(mv.getMonth()));
      month.setModel(monthsModel);
      month.setSelectedIndex(selected);
      month.addActionListener(mv);

      java.util.Calendar cal = java.util.Calendar.getInstance(tmz);
      cal.setTime(new java.util.Date(time));
      month.getStyle().setBgTransparency(0);
      int y = cal.get(java.util.Calendar.YEAR);
      Vector years = new Vector();
      for (int i = 2100; i >= 1900; i--) {
        years.addElement("" + i);
      }
      ListModel yearModel = new DefaultListModel(years);
      selected = years.indexOf("" + y);
      year.setModel(yearModel);
      year.setSelectedIndex(selected);
      year.getStyle().setBgTransparency(0);
      year.addActionListener(mv);
      Container cnt = new Container(new BoxLayout(BoxLayout.X_AXIS));
      cnt.setRTL(false);

      Container dateCnt = new Container(new BoxLayout(BoxLayout.X_AXIS));
      dateCnt.setUIID("CalendarDate");
      dateCnt.addComponent(month);
      dateCnt.addComponent(year);
      cnt.addComponent(dateCnt);

      Container upper = new Container(new FlowLayout(Component.CENTER));
      upper.addComponent(cnt);

      addComponent(BorderLayout.NORTH, upper);
    }
    addComponent(BorderLayout.CENTER, mv);
  }
コード例 #9
0
ファイル: ScrollBar.java プロジェクト: EricEidel/Game3
  /**
   * Sets the appearance for this scroll bar. If <code>appearance</code> is not an instance of
   * ScrollBarAppearance, an <code>IllegalArgumentException</code> is thrown.
   *
   * @param appearance the new appearance to set
   */
  public void setAppearance(ComponentAppearance appearance) {
    if (appearance == null)
      throw new IllegalStateException("null appearance not allowed with ScrollBar");
    if (!(appearance instanceof ScrollBarAppearance)) {
      throw new IllegalArgumentException("appearance must be instance of ScrollBarAppearance");
    }
    super.setAppearance(appearance);

    // de-init components
    if (slider != null) {
      remove(slider);
      slider.removeMouseWheelListener(incDecListener);
      slider.getThumbButton().removeMouseWheelListener(incDecListener);
      // slider.getDelayTimer().removeActionListener(delayListener);

    }
    if (incButton != null) {
      remove(incButton);
      incButton.removeActionListener(incDecListener);
    }
    if (decButton != null) {
      remove(decButton);
      decButton.removeActionListener(incDecListener);
    }

    // re-init components

    // gets the current appearance
    ScrollBarAppearance a = (ScrollBarAppearance) this.getAppearance();
    if (a == null) {
      throw new IllegalStateException("no appearance set for this scroll bar");
    }

    // creates scroll & thumb buttons
    // skins can choose how they should be created
    incButton = a.createScrollButton(this, INCREMENT);
    decButton = a.createScrollButton(this, DECREMENT);
    slider = a.createSlider(this, orientation);

    if (incButton == null || decButton == null || slider == null)
      throw new NullPointerException("null components passed to scroll bar");
    if (slider.getOrientation() != orientation)
      throw new IllegalArgumentException("passed slider doesn't match orientation of scroll bar");

    // add scroll listeners buttons
    incButton.addActionListener(incDecListener);
    decButton.addActionListener(incDecListener);
    // slider.getDelayTimer().addActionListener(delayListener);

    // add the new components to this bar
    add(slider);
    add(incButton);
    add(decButton);

    incButton.addMouseWheelListener(incDecListener);
    decButton.addMouseWheelListener(incDecListener);
    slider.addMouseWheelListener(incDecListener);
    slider.getThumbButton().addMouseWheelListener(incDecListener);
    addMouseWheelListener(incDecListener);

    updateWidth();
    updateHeight();
  }
コード例 #10
0
  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.
  }