@return a copy of this menu as a swing JMenu, with all elements converted to their respective swing elements. Modifications to the elements of the new JMenu will not affect anything, as they are all copies
()
| 323 | * @return a copy of this menu as a swing JMenu, with all elements converted to their respective swing elements. Modifications to the elements of the new JMenu will not affect anything, as they are all copies |
| 324 | */ |
| 325 | @Override |
| 326 | public |
| 327 | JMenu asSwingComponent() { |
| 328 | JMenu jMenu = new JMenu(); |
| 329 | |
| 330 | if (getImage() != null) { |
| 331 | jMenu.setIcon(new ImageIcon(getImage().getAbsolutePath())); |
| 332 | } |
| 333 | jMenu.setText(getText()); |
| 334 | jMenu.setToolTipText(getTooltip()); |
| 335 | jMenu.setEnabled(getEnabled()); |
| 336 | jMenu.setMnemonic(SwingUtil.INSTANCE.getVirtualKey(getShortcut())); |
| 337 | |
| 338 | |
| 339 | synchronized (menuEntries) { |
| 340 | for (final Entry menuEntry : menuEntries) { |
| 341 | if (menuEntry instanceof Menu) { |
| 342 | Menu entry = (Menu) menuEntry; |
| 343 | jMenu.add(entry.asSwingComponent()); |
| 344 | } |
| 345 | else if (menuEntry instanceof Checkbox) { |
| 346 | Checkbox entry = (Checkbox) menuEntry; |
| 347 | jMenu.add(entry.asSwingComponent()); |
| 348 | } |
| 349 | else if (menuEntry instanceof MenuItem) { |
| 350 | MenuItem entry = (MenuItem) menuEntry; |
| 351 | jMenu.add(entry.asSwingComponent()); |
| 352 | } |
| 353 | else if (menuEntry instanceof Separator) { |
| 354 | Separator entry = (Separator) menuEntry; |
| 355 | jMenu.add(entry.asSwingComponent()); |
| 356 | } |
| 357 | else if (menuEntry instanceof Status) { |
| 358 | Status entry = (Status) menuEntry; |
| 359 | jMenu.add(entry.asSwingComponent()); |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | return jMenu; |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * This removes a menu entry from the menu. |
nothing calls this directly
no test coverage detected