本文整理汇总了Java中javax.swing.JMenuItem.setAction方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuItem.setAction方法的具体用法?Java JMenuItem.setAction怎么用?Java JMenuItem.setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenuItem
的用法示例。
在下文中一共展示了JMenuItem.setAction方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KMeanScatterPopupMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
restore = new JMenuItem("Original view");
saveAs = new JMenuItem("Save as...");
clusters = new JMenu("Clusters");
printClusterInfo = new JMenuItem("Save info...");
point = new JMenu("Point size");
for (int i = 0; i < 5; i++) {
JMenuItem m = new JMenuItem();
m.setAction(commonActionSize);
m.setText("Size " + Integer.toString((i + 1)));
point.add(m);
}
this.add(restore);
this.addSeparator();
this.add(point);
this.addSeparator();
this.add(saveAs);
this.addSeparator();
this.add(printClusterInfo);
this.addSeparator();
this.add(clusters);
addListeners();
}
示例2: ScatterPopupMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public ScatterPopupMenu() {
restore = new JMenuItem("Original view");
saveAs = new JMenuItem("Save as...");
point = new JMenu("Point size");
for (int i = 0; i < 5; i++) {
JMenuItem m = new JMenuItem();
m.setAction(commonActionSize);
m.setText("Size " + Integer.toString((i + 1)));
point.add(m);
}
this.add(restore);
this.addSeparator();
this.add(point);
this.addSeparator();
this.add(saveAs);
addListeners();
}
示例3: KMeanSingleClusterScatterPopupMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanSingleClusterScatterPopupMenu() {
restore = new JMenuItem("Original view");
saveAs = new JMenuItem("Save as...");
clusters = new JMenu("Cluster");
printClusterInfo = new JMenuItem("Save info...");
point = new JMenu("Point size");
for (int i = 0; i < 3; i++) {
JMenuItem m = new JMenuItem();
m.setAction(commonActionSize);
m.setText("Size " + Integer.toString((i + 1)));
point.add(m);
}
this.add(restore);
this.addSeparator();
this.add(point);
this.addSeparator();
this.add(saveAs);
this.addSeparator();
this.add(printClusterInfo);
this.addSeparator();
this.add(clusters);
addListeners();
}
示例4: KMeanScatterPopupMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
restore = new JMenuItem("Original view");
saveAs = new JMenuItem("Save as...");
clusters = new JMenu("Cluster");
printClusterInfo = new JMenuItem("Save info...");
point = new JMenu("Point size");
for (int i = 0; i < 3; i++) {
JMenuItem m = new JMenuItem();
m.setAction(commonActionSize);
m.setText("Size " + Integer.toString((i + 1)));
point.add(m);
}
this.add(restore);
this.addSeparator();
this.add(point);
this.addSeparator();
this.add(saveAs);
this.addSeparator();
this.add(printClusterInfo);
this.addSeparator();
this.add(clusters);
addListeners();
}
示例5: KMeanScatterPopupMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
restore = new JMenuItem("Original view");
saveAs = new JMenuItem("Save as...");
//clusters = new JMenu("Clusters");
printClusterInfo = new JMenuItem("Save info...");
point = new JMenu("Point size");
for (int i = 0; i < 5; i++) {
JMenuItem m = new JMenuItem();
m.setAction(commonActionSize);
m.setText("Size " + Integer.toString((i + 1)));
point.add(m);
}
this.add(restore);
this.addSeparator();
this.add(point);
this.addSeparator();
this.add(saveAs);
this.addSeparator();
this.add(printClusterInfo);
//this.addSeparator();
//this.add(clusters);
addListeners();
}
示例6: setActionMenuBar
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void setActionMenuBar(String menuItem, Action action) {
for (int i = 0; i < mMenuBar.getMenuCount(); i++) {
JMenu menu = mMenuBar.getMenu(i);
for (int j = 0; j < menu.getMenuComponentCount(); j++) {
Component component = menu.getMenuComponent(j);
if (component instanceof JMenuItem) {
JMenuItem item = (JMenuItem) component;
String description = (String) item.getAction().getValue(Action.SHORT_DESCRIPTION);
if (description.equals(menuItem)) {
item.setAction(action);
item.setText(menuItem);
break;
}
}
}
}
}
示例7: getPopupPresenter
import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
@Messages({"ACT_Show=Show in POM",
"# {0} - artifactid of a project",
"ACT_Current=Current: {0}",
"# {0} - artifactid of a project",
"ACT_PARENT=Parent: {0}"})
public JMenuItem getPopupPresenter() {
JMenu menu = new JMenu();
menu.setText(ACT_Show());
POMCutHolder pch = node.getLookup().lookup(POMCutHolder.class);
POMModel[] mdls = pch.getSource();
Object[] val = pch.getCutValues();
int index = 0;
for (POMModel mdl : mdls) {
String artifact = mdl.getProject().getArtifactId();
JMenuItem item = new JMenuItem();
item.setAction(new SelectAction(node, index));
if (index == 0) {
item.setText(ACT_Current(artifact != null ? artifact : "project"));
} else {
item.setText(ACT_PARENT(artifact != null ? artifact : "project"));
}
item.setEnabled(/* #199345 */index < val.length && val[index] != null);
menu.add(item);
index++;
}
return menu;
}
示例8: setMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
/** Sets the state of JMenuItem*/
protected @Override void setMenu(){
ActionMap am = getContextActionMap();
Action action = null;
if (am != null) {
action = am.get(getActionName());
}
JMenuItem presenter = getMenuPresenter();
Action presenterAction = presenter.getAction();
if (presenterAction == null){
presenter.setAction(this);
presenter.setToolTipText(null); /* bugfix #62872 */
menuInitialized = false;
}
else {
if (!this.equals(presenterAction)){
presenter.setAction(this);
presenter.setToolTipText(null); /* bugfix #62872 */
menuInitialized = false;
}
}
if (!menuInitialized){
Mnemonics.setLocalizedText(presenter, getMenuItemText());
menuInitialized = true;
}
presenter.setEnabled(action != null);
JTextComponent comp = Utilities.getFocusedComponent();
if (comp != null && comp instanceof JEditorPane){
addAccelerators(this, presenter, comp);
} else {
presenter.setAccelerator(getDefaultAccelerator());
}
}
示例9: showPopup
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void showPopup(JComponent source) {
final JPopupMenu popup = new JPopupMenu();
for (Enumeration<?> e = addressBook.elements(); e.hasMoreElements();) {
final AddressBookEntry entry = (AddressBookEntry) e.nextElement();
final JMenuItem item = new JMenuItem(entry.toString());
final AbstractAction action = new MenuAction(entry);
item.setAction(action);
item.setIcon(entry.getIcon(IconFamily.SMALL));
popup.add(item);
}
popup.show(source, 0, 0);
}