1 14 package org.wings; 15 16 import org.wings.plaf.PopupMenuCG; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 25 public class SPopupMenu 26 extends SComponent { 27 protected final List menuItems = new ArrayList (); 28 private double widthScaleFactor = 0.7f; 29 30 33 public void add(SMenuItem menuItem) { 34 menuItems.add(menuItem); 35 menuItem.setParentMenu(this); 36 } 37 38 41 public void add(SComponent menuItem) { 42 menuItems.add(menuItem); 43 menuItem.setParentFrame(getParentFrame()); 44 } 45 46 public void setParentFrame(SFrame f) { 47 super.setParentFrame(f); 48 for (int i = 0; i < menuItems.size(); i++) { 49 ((SComponent) menuItems.get(i)).setParentFrame(f); 50 } 51 } 52 53 56 public void add(String menuitem) { 57 this.add(new SMenuItem(menuitem)); 58 } 59 60 public SComponent getMenuComponent(int pos) { 61 return (SComponent) menuItems.get(pos); 62 } 63 64 67 public int getMenuComponentCount() { 68 return menuItems.size(); 69 } 70 71 74 public void removeAll() { 75 while (menuItems.size() > 0) { 76 remove(0); 77 } 78 } 79 80 83 public void remove(int pos) { 84 remove(getMenuComponent(pos)); 85 } 86 87 90 public void remove(SComponent comp) { 91 menuItems.remove(comp); 92 comp.setParentFrame(null); 93 } 94 95 public void setCG(PopupMenuCG cg) { 96 super.setCG(cg); 97 } 98 99 106 public double getWidthScaleFactor() { 107 return widthScaleFactor; 108 } 109 118 public void setWidthScaleFactor(double widthScaleFactor) { 119 this.widthScaleFactor = widthScaleFactor; 120 } 121 } 122 | Popular Tags |