229
230 return sm;
231 }
232
233 /**
234 * Remove the screen menu associated with the specifiec menu. This
235 * also removes any associated component listener on the screen menu
236 * and removes the key/value (menu/screen menu) from the fSubmenus cache.
237 *
238 * @param menu The swing menu we want to remove the screen menu for.
239 */
240 private void removeSubmenu(final JMenu menu) {
241 final ScreenMenu screenMenu = fSubmenus.get(menu);
242 if (screenMenu == null) return;
243
244 menu.removeComponentListener(this);
245 remove(screenMenu);
246 fSubmenus.remove(menu);
247 }
248
249 public Menu add(final Menu m, final int index) {
250 synchronized (getTreeLock()) {
251 if (m.getParent() != null) {
252 m.getParent().remove(m);
253 }
254
255 final Vector<Menu> menus = AWTAccessor.getMenuBarAccessor().getMenus(this);
256 menus.insertElementAt(m, index);
257 AWTAccessor.getMenuComponentAccessor().setParent(m, this);
258
259 final CMenuBar peer = (CMenuBar)getPeer();
260 if (peer == null) return m;
261
262 peer.setNextInsertionIndex(index);
263 if (m.getPeer() == null) {
264 m.addNotify();
265 }
266
267 peer.setNextInsertionIndex(-1);
268 return m;
|
229
230 return sm;
231 }
232
233 /**
234 * Remove the screen menu associated with the specifiec menu. This
235 * also removes any associated component listener on the screen menu
236 * and removes the key/value (menu/screen menu) from the fSubmenus cache.
237 *
238 * @param menu The swing menu we want to remove the screen menu for.
239 */
240 private void removeSubmenu(final JMenu menu) {
241 final ScreenMenu screenMenu = fSubmenus.get(menu);
242 if (screenMenu == null) return;
243
244 menu.removeComponentListener(this);
245 remove(screenMenu);
246 fSubmenus.remove(menu);
247 }
248
249 @SuppressWarnings("deprecation")
250 public Menu add(final Menu m, final int index) {
251 synchronized (getTreeLock()) {
252 if (m.getParent() != null) {
253 m.getParent().remove(m);
254 }
255
256 final Vector<Menu> menus = AWTAccessor.getMenuBarAccessor().getMenus(this);
257 menus.insertElementAt(m, index);
258 AWTAccessor.getMenuComponentAccessor().setParent(m, this);
259
260 final CMenuBar peer = (CMenuBar)getPeer();
261 if (peer == null) return m;
262
263 peer.setNextInsertionIndex(index);
264 if (m.getPeer() == null) {
265 m.addNotify();
266 }
267
268 peer.setNextInsertionIndex(-1);
269 return m;
|