use of javax.swing.MenuElement in project zaproxy by zaproxy.
the class MainPopupMenu method setVisible.
/**
* {@inheritDoc}
* <p>
* Overridden to call the method {@code ExtensionPopupMenuComponent#dismissed(ExtensionPopupMenuComponent)} of child
* {@code ExtensionPopupMenuComponent}s when the pop up menu is hidden.
*
* @see ExtensionPopupMenuComponent#dismissed(ExtensionPopupMenuComponent)
*/
@Override
public void setVisible(boolean b) {
super.setVisible(b);
if (!b) {
ExtensionPopupMenuComponent selectedMenuComponent = null;
if (pathSelectedMenu != null) {
MenuElement selectedMenuElement = pathSelectedMenu[pathSelectedMenu.length - 1];
if (PopupMenuUtils.isExtensionPopupMenuComponent(selectedMenuElement)) {
selectedMenuComponent = (ExtensionPopupMenuComponent) selectedMenuElement;
}
pathSelectedMenu = null;
}
for (int i = 0; i < getComponentCount(); i++) {
Component component = getComponent(i);
if (PopupMenuUtils.isExtensionPopupMenuComponent(component)) {
((ExtensionPopupMenuComponent) component).dismissed(selectedMenuComponent);
}
}
}
}
use of javax.swing.MenuElement in project JMRI by JMRI.
the class AudioTableAction method setMenuBar.
@Override
public void setMenuBar(BeanTableFrame f) {
JMenuBar menuBar = f.getJMenuBar();
ResourceBundle rbapps = ResourceBundle.getBundle("apps.AppsBundle");
MenuElement[] subElements;
JMenu fileMenu = null;
for (int i = 0; i < menuBar.getMenuCount(); i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuFile"))) {
fileMenu = menuBar.getMenu(i);
}
}
}
if (fileMenu == null) {
return;
}
subElements = fileMenu.getSubElements();
for (MenuElement subElement : subElements) {
MenuElement[] popsubElements = subElement.getSubElements();
for (MenuElement popsubElement : popsubElements) {
if (popsubElement instanceof JMenuItem) {
if (((JMenuItem) popsubElement).getText().equals(rbapps.getString("PrintTable"))) {
JMenuItem printMenu = (JMenuItem) popsubElement;
fileMenu.remove(printMenu);
break;
}
}
}
}
fileMenu.add(atp.getPrintItem());
}
use of javax.swing.MenuElement in project jmeter by apache.
the class MainFrame method closeMenu.
/**
* Close the currently selected menu.
*/
public void closeMenu() {
if (menuBar.isSelected()) {
MenuElement[] menuElement = menuBar.getSubElements();
if (menuElement != null) {
for (MenuElement element : menuElement) {
JMenu menu = (JMenu) element;
if (menu.isSelected()) {
menu.setPopupMenuVisible(false);
menu.setSelected(false);
break;
}
}
}
}
}
use of javax.swing.MenuElement in project jmeter by apache.
the class JMeterMenuBar method updateMenuElement.
/**
* <p>Refreshes all texts in the menu and all submenus to a new locale.</p>
*
* <p>Assumes that the item name is set to the resource key, so the resource can be retrieved.
* Certain action types do not follow this rule, @see JMeterMenuBar#isNotResource(String)</p>
*
* The Language Change event assumes that the name is the same as the locale name,
* so this additionally means that all supported locales must be defined as resources.
*
*/
private void updateMenuElement(MenuElement menu) {
Component component = menu.getComponent();
final String compName = component.getName();
if (compName != null) {
for (MenuCreator menuCreator : menuCreators) {
if (menuCreator.localeChanged(menu)) {
return;
}
}
if (component instanceof JMenu) {
final JMenu jMenu = (JMenu) component;
if (isResource(jMenu.getActionCommand())) {
jMenu.setText(JMeterUtils.getResString(compName));
}
} else {
final JMenuItem jMenuItem = (JMenuItem) component;
if (isResource(jMenuItem.getActionCommand())) {
jMenuItem.setText(JMeterUtils.getResString(compName));
} else if (ActionNames.CHANGE_LANGUAGE.equals(jMenuItem.getActionCommand())) {
jMenuItem.setText(JMeterUtils.getLocaleString(compName));
}
}
}
for (MenuElement subElement : menu.getSubElements()) {
updateMenuElement(subElement);
}
}
Aggregations