本文整理汇总了Java中javax.swing.JMenu.removeAll方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.removeAll方法的具体用法?Java JMenu.removeAll怎么用?Java JMenu.removeAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.removeAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBindingsSubmenu
import javax.swing.JMenu; //导入方法依赖的package包/类
private void createBindingsSubmenu(JMenu menu) {
if (menu.getMenuComponentCount() > 0)
menu.removeAll();
Node[] nodes = getActivatedNodes();
if (nodes.length != 1)
return;
RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
if (radCookie == null)
return;
BindingProperty[][] bindingProps = radCookie.getRADComponent().getBindingProperties();
BindingProperty[] props = bindingProps[(bindingProps[0].length==0) ? 1 : 0];
if (props.length > 0) {
for (BindingProperty prop : props) {
BindingMenuItem mi = new BindingMenuItem(prop);
mi.addActionListener(mi);
menu.add(mi);
}
} else {
JMenuItem item = new JMenuItem(NbBundle.getMessage(BindAction.class, "MSG_NoBinding")); // NOI18N
item.setEnabled(false);
menu.add(item);
}
}
示例2: setProjectMenuItems
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Create's the Window=>MenuItems depending on the open projects
*/
private void setProjectMenuItems() {
boolean setFontBold = true;
JMenu WindowMenu = Application.getMainWindow().getJMenuMainWindow();
WindowMenu.removeAll();
if (this.count()==0 ){
WindowMenu.add( new JMenuItmen_Window( Language.translate("Kein Projekt geöffnet !"), -1, setFontBold ) );
} else {
for(int i=0; i<this.count(); i++) {
String ProjectName = this.getProjectsOpen().get(i).getProjectName();
if ( ProjectName.equalsIgnoreCase( Application.getProjectFocused().getProjectName() ) )
setFontBold = true;
else
setFontBold = false;
WindowMenu.add( new JMenuItmen_Window( ProjectName, i, setFontBold) );
}
}
}
示例3: updateMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Add list orecentProjFile recent projects as Menu Items to the Recent
* projects menu
*
*
* @param recentProj instance orecentProjFile the menu to address
* <code>Recent Projects</code>
*/
public void updateMenu(JMenu recentProj) {
recentProj.removeAll();
try {
for (String file : recentProjects) {
recentItemMenu = new JMenuItem();
recentItemMenu.setFont(new java.awt.Font("sansserif", 0, 11));
recentItemMenu.setText(toName(file));
recentItemMenu.setToolTipText(file);
recentProj.add(recentItemMenu);
addlistener(recentItemMenu);
}
} catch (Exception ex) {
Logger.getLogger(RecentItems.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例4: recreateStateMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
private void recreateStateMenu(JMenu menu, ArrayList<CircuitStateMenuItem> items, int code) {
menu.removeAll();
menu.setEnabled(items.size() > 0);
boolean first = true;
int mask = getToolkit().getMenuShortcutKeyMask();
for (int i = items.size() - 1; i >= 0; i--) {
JMenuItem item = items.get(i);
menu.add(item);
if (first) {
item.setAccelerator(KeyStroke.getKeyStroke(code, mask));
first = false;
} else {
item.setAccelerator(null);
}
}
}
示例5: menuDeselected
import javax.swing.JMenu; //导入方法依赖的package包/类
public void menuDeselected(MenuEvent e) {
JMenu wm = (JMenu) e.getSource();
// Cleans Windows if not visible
if(wm.getText().matches("Windows") || wm.getText().matches("Window")) {
wm.removeAll();
System.gc();
}
/* When user first imports menu item the background is set to another color to catch user attention.
* After user interaction will set the background color back.
*/
if(wm.getText().matches("My Layer Sessions")) {
JMenu selectSessionMenu = (JMenu) wm;
try {
JMenuItem selectSessionMenuChild = (JMenuItem) selectSessionMenu.getMenuComponent(0);
Color currentColor = selectSessionMenu.getBackground();
Color defaultColor = selectSessionMenuChild.getBackground();
if(currentColor.getRed() + currentColor.getGreen() + currentColor.getBlue() == 586) {
selectSessionMenu.setBackground(defaultColor);
selectSessionMenu.revalidate();
}
} catch (Exception ex) {
//don't do anything if menu component and cannot be cast as a JMenuItem
//(eg if it is a separator bar)
}
}
}
示例6: fillSubMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
@Messages({
"LBL_NewFileAction_File_PopupName=Other...",
"NewFile.please_wait=Please wait..."
})
private void fillSubMenu(final JMenu menuItem, final Lookup lookup) {
menuItem.removeAll();
JMenuItem wait = new JMenuItem(NewFile_please_wait());
wait.setEnabled(false);
menuItem.add(wait);
final Pair<List<Project>, List<FileObject>> data = ActionsUtil.mineFromLookup(lookup);
RP.post(new Runnable() {
@Override public void run() {
Project projects[] = ActionsUtil.getProjects(data);
final Project project = projects.length > 0 ? projects[0] : null;
final List<TemplateItem> items = OpenProjectList.prepareTemplates(project, getLookup());
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
menuItem.removeAll();
ActionListener menuListener = new PopupListener();
for (TemplateItem i : items) {
JMenuItem item = new JMenuItem(
LBL_NewFileAction_Template_PopupName(i.displayName),
i.icon);
item.addActionListener(menuListener);
item.putClientProperty(TEMPLATE_PROPERTY, i.template);
item.putClientProperty(IN_PROJECT_PROPERTY, project != null);
menuItem.add(item);
}
if (!items.isEmpty()) {
menuItem.add(new Separator());
}
JMenuItem fileItem = new JMenuItem(LBL_NewFileAction_File_PopupName(), (Icon) getValue(Action.SMALL_ICON));
fileItem.addActionListener(menuListener);
fileItem.putClientProperty(TEMPLATE_PROPERTY, null);
fileItem.putClientProperty(IN_PROJECT_PROPERTY, project != null);
menuItem.add(fileItem);
// #205616 - need to refresh please wait node
menuItem.getPopupMenu().pack();
}
});
}
});
}
示例7: depopulateMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
protected void depopulateMenu (String containerCtx, JMenu menu) {
menu.removeAll();
}