예제 #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());
          }
        });
  }
예제 #2
0
 public void actionPerformed(ActionEvent evt) {
   int newSelected = ((List) evt.getSource()).getSelectedIndex();
   list.setListCellRenderer(renderers[newSelected]);
   list.requestFocus();
   list.getParent().revalidate();
 }