本文整理汇总了Java中javax.swing.JMenuItem.getText方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuItem.getText方法的具体用法?Java JMenuItem.getText怎么用?Java JMenuItem.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenuItem
的用法示例。
在下文中一共展示了JMenuItem.getText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
* ActionListener interface implementation
* This would presumably handle menu selections, but none of them actually
* do anything now.
*/
public void actionPerformed(ActionEvent e) {
if ( DEBUG ) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Action event detected." // NOI18N
+ "\n" // NOI18N
+ " Event source: " + source.getText() // NOI18N
+ " (an instance of " + getClassName(source) + ")"; // NOI18N
System.out.println (s + "\n"); // NOI18N
}
}
示例2: getItemText
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public static String getItemText(JMenuItem current) {
String text = current.getText();
if (text == null || "".equals(text)) {
return getTextFromIcon(current);
}
return text;
}
示例3: actionPerformed
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) (e.getSource());
String s = "Action event detected." + newline + " Event source: " + source.getText() + " (an instance of "
+ getClassName(source) + ")";
output.append(s + newline);
output.setCaretPosition(output.getDocument().getLength());
}
示例4: actionPerformed
import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem btn = (JMenuItem) e.getSource();
if(btn.getText() == "Github") {
openSite("https://condolent.github.io/USB3Installer/");
}
if(btn.getText() == "Exit") {
System.exit(ABORT);
}
if(btn.getText() == "About") {
System.out.println("About clicked.\nCalled popup.");
openAbout();
}
if(btn.getText() == "How do I use this?") {
openSite("https://github.com/condolent/USB3Installer/wiki");
}
if(btn.getText() == "Report a bug") {
openSite("https://github.com/condolent/USB3Installer/issues");
}
/*if(btn.getText() == "Choose Workspace") {
System.out.println("Choose Workspace clicked.");
System.err.println("This function isn't finished yet.");
}*/
}
示例5: itemStateChanged
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem) (e.getSource());
String s = "Item event detected." + newline + " Event source: " + source.getText() + " (an instance of "
+ getClassName(source) + ")" + newline + " New state: "
+ ((e.getStateChange() == ItemEvent.SELECTED) ? "selected" : "unselected");
output.append(s + newline);
output.setCaretPosition(output.getDocument().getLength());
}
示例6: itemStateChanged
import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Item event detected."
+ newline
+ " Event source: " + source.getText()
+ " (an instance of " + getClassName(source) + ")"
+ newline
+ " New state: "
+ ((e.getStateChange() == ItemEvent.SELECTED) ?
"selected":"unselected");
output.append(s + newline);
output.setCaretPosition(output.getDocument().getLength());
}
示例7: itemStateChanged
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Item event detected.\n"
+ " Event source: " + source.getText()
+ " (an instance of " + source.getClass().getName() + ")\n"
+ " New state: "
+ ((e.getStateChange() == ItemEvent.SELECTED) ?
"selected":"unselected") + "\n\n";
System.err.println(s);
}
示例8: itemStateChanged
import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Item event detected.\n"
+ " Event source: " + source.getText()
+ " (an instance of " + source.getClass().getName() + ")\n"
+ " New state: "
+ ((e.getStateChange() == ItemEvent.SELECTED) ?
"selected":"unselected") + "\n\n";
System.err.println(s);
}
示例9: actionPerformed
import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
JMenuItem source = (JMenuItem)ae.getSource();
String s = "Action event detected."
+ newline
+ " Event source: " + source.getText()
+ " (an instance of " + getClassName(source) + ")";
output.append(s + newline);
output.setCaretPosition(output.getDocument().getLength());
}
示例10: actionPerformed
import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) (e.getSource());
String s = "Action event detected." + newline + " Event source: "
+ source.getText();
System.out.println(s);
if (source.getText().equals("new galton-watson tree")) {
t.clear();
GeometricTree.galtonWatsonTree(t, 100);
t.inorderDraw();
output.repaint();
} else if (source.getText().equals("new complete binary tree")) {
t.clear();
GeometricTree.completeBinaryTree(t, 50);
t.inorderDraw();
output.repaint();
} else if (source.getText().equals("in-order layout")) {
t.inorderDraw();
output.repaint();
} else if (source.getText().equals("leftist layout")) {
t.leftistDraw();
output.repaint();
} else if (source.getText().equals("balanced layout")) {
t.balancedDraw();
output.repaint();
}
}
示例11: NbMenu
import javax.swing.JMenuItem; //导入方法依赖的package包/类
NbMenu(JMenuItem menu, List<NbMenu> submenu) {
name = menu.getText();//getLabel();
accelerator = (menu.getAccelerator() == null) ? null : menu.getAccelerator().toString();
mnemo = menu.getMnemonic();
this.submenu = submenu;
}