Removes a menu with the given name from the menu bar and returns the removed item. Returns null if menu item does not exist. @param menuName String @return JMenu
(String menuName)
| 510 | * @return JMenu |
| 511 | */ |
| 512 | public JMenu removeMenu(String menuName) { |
| 513 | JMenuBar menuBar = getJMenuBar(); |
| 514 | if (menuBar == null) { |
| 515 | return null; |
| 516 | } |
| 517 | menuName = menuName.trim(); |
| 518 | JMenu menu = null; |
| 519 | for (int i = 0; i < menuBar.getMenuCount(); i++) { |
| 520 | JMenu next = menuBar.getMenu(i); |
| 521 | if (next.getText().trim().equals(menuName)) { |
| 522 | menu = next; |
| 523 | menuBar.remove(i); |
| 524 | break; |
| 525 | } |
| 526 | } |
| 527 | return menu; |
| 528 | } |
| 529 | |
| 530 | /** |
| 531 | * Removes a menu item with the given name from the menu bar and returns the |
no test coverage detected