本文整理匯總了Java中java.awt.Menu.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Menu.add方法的具體用法?Java Menu.add怎麽用?Java Menu.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Menu
的用法示例。
在下文中一共展示了Menu.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initProjectMenu
import java.awt.Menu; //導入方法依賴的package包/類
private static Menu initProjectMenu() {
Menu mnProject = new Menu(Resources.get("menu_project"));
CheckboxMenuItem compress = new CheckboxMenuItem(Resources.get("menu_compressProjectFile"));
compress.setState(userPreferences.isCompressFile());
compress.addItemListener(e -> userPreferences.setCompressFile(compress.getState()));
CheckboxMenuItem sync = new CheckboxMenuItem(Resources.get("menu_syncMaps"));
sync.setState(userPreferences.isSyncMaps());
sync.addItemListener(e -> userPreferences.setSyncMaps(sync.getState()));
MenuItem importSpriteFile = new MenuItem(Resources.get("menu_assets_importSpriteFile"));
importSpriteFile.addActionListener(a -> EditorScreen.instance().importSpriteFile());
MenuItem importSprite = new MenuItem(Resources.get("menu_assets_importSprite"));
importSprite.addActionListener(a -> EditorScreen.instance().importSprites());
mnProject.add(importSprite);
mnProject.add(importSpriteFile);
mnProject.addSeparator();
mnProject.add(compress);
mnProject.add(sync);
return mnProject;
}
示例2: generateMenuItem
import java.awt.Menu; //導入方法依賴的package包/類
private static MenuItem generateMenuItem(TreeElement element) {
if(element.isLeaf()) {
MenuItem item = new MenuItem(element.getCaption());
item.addActionListener(new MasterFrameMenu(element.getFullID()));
if(element.isHidden()) {
item.setEnabled(false);
} else if(!element.getEnabled()) {
item.setEnabled(false);
}
items.put(element.getFullID(), item);
return(item);
} else {
Menu menu = new Menu(element.getCaption());
Iterator<TreeElement> i = element.getChilds();
while(i.hasNext()) {
menu.add(generateMenuItem(i.next()));
}
if(element.isHidden()) {
menu.setEnabled(false);
}
items.put(element.getFullID(), menu);
return(menu);
}
}
示例3: addMenuItems
import java.awt.Menu; //導入方法依賴的package包/類
/**
* Method declaration
*
*
* @param f
* @param m
*/
private void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
if (m[i].equals("-")) {
f.addSeparator();
} else {
MenuItem item = new MenuItem(m[i]);
item.addActionListener(this);
f.add(item);
}
}
}
示例4: main
import java.awt.Menu; //導入方法依賴的package包/類
public static void main(String[] args) {
Container container = new Container();
Panel panel = new Panel();
Menu menu = new Menu(); //!!! its not component
TextField textField = new TextField();
container.add(textField);
Window win = new Window(null);
win.pack();
menu.setShortcut(new MenuShortcut(12));
new MenuItem("label", new MenuShortcut(33, true));
Menu file = new Menu("File");
MenuItem print;
file.add(print = new MenuItem("Print", new MenuShortcut('p')));
}
示例5: createPopupMenu
import java.awt.Menu; //導入方法依賴的package包/類
protected static PopupMenu createPopupMenu() {
final PopupMenu popup = new PopupMenu();
MenuItem aboutItem = new MenuItem("About");
CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
Menu displayMenu = new Menu("Display");
MenuItem errorItem = new MenuItem("Error");
MenuItem warningItem = new MenuItem("Warning");
MenuItem infoItem = new MenuItem("Info");
MenuItem noneItem = new MenuItem("None");
MenuItem exitItem = new MenuItem("Exit");
// Add components to pop-up menu
popup.add(aboutItem);
popup.addSeparator();
popup.add(cb1);
popup.add(cb2);
popup.addSeparator();
popup.add(displayMenu);
displayMenu.add(errorItem);
displayMenu.add(warningItem);
displayMenu.add(infoItem);
displayMenu.add(noneItem);
popup.add(exitItem);
return popup;
}
示例6: OpenPartnerFrame
import java.awt.Menu; //導入方法依賴的package包/類
public OpenPartnerFrame (Go go)
{
super(Global.resourceString("Open_Partners"));
G = go;
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu m = new MyMenu(Global.resourceString("Options"));
m.add(new MenuItemAction(this, Global.resourceString("Close")));
mb.add(m);
setLayout(new BorderLayout());
L = new java.awt.List();
L.setFont(Global.SansSerif);
refresh();
add("Center", L);
JPanel bp = new MyPanel();
bp.add(new ButtonAction(this, Global.resourceString("Connect")));
bp.add(new ButtonAction(this, Global.resourceString("Refresh")));
bp.add(new MyLabel(" "));
bp.add(new ButtonAction(this, Global.resourceString("Close")));
add("South", bp);
Global.setwindow(this, "openpartner", 300, 200);
seticon("ijago.gif");
setVisible(true);
OPFU = new OpenPartnerFrameUpdate(this);
}
示例7: initFileMenu
import java.awt.Menu; //導入方法依賴的package包/類
private static Menu initFileMenu() {
Menu mnFile = new Menu(Resources.get("menu_file"));
MenuItem create = new MenuItem(Resources.get("menu_createProject"));
create.setShortcut(new MenuShortcut(KeyEvent.VK_N));
create.addActionListener(a -> EditorScreen.instance().create());
MenuItem load = new MenuItem(Resources.get("menu_loadProject"));
load.setShortcut(new MenuShortcut(KeyEvent.VK_O));
load.addActionListener(a -> EditorScreen.instance().load());
MenuItem save = new MenuItem(Resources.get("menu_save"));
save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
save.addActionListener(a -> EditorScreen.instance().save(false));
MenuItem saveAs = new MenuItem(Resources.get("menu_saveAs"));
saveAs.addActionListener(a -> EditorScreen.instance().save(true));
MenuItem exit = new MenuItem(Resources.get("menu_exit"));
exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
exit.addActionListener(a -> Game.terminate());
mnFile.add(load);
mnFile.add(create);
mnFile.add(save);
mnFile.add(saveAs);
mnFile.addSeparator();
recentFiles = new Menu(Resources.get("menu_recentFiles"));
loadRecentFiles();
mnFile.add(recentFiles);
mnFile.addSeparator();
mnFile.add(exit);
return mnFile;
}
示例8: addMenuItems
import java.awt.Menu; //導入方法依賴的package包/類
void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
示例9: main
import java.awt.Menu; //導入方法依賴的package包/類
/**
* Method declaration
*
*
* @param arg
*/
public static void main(String[] arg) {
fMain = new Frame("Query Tool");
QueryTool q = new QueryTool();
q.bApplication = true;
for (int i = 0; i < arg.length; i++) {
String p = arg[i];
if (p.equals("-?")) {
printHelp();
}
if (p.charAt(0) == '-') {
pProperties.put(p.substring(1), arg[i + 1]);
i++;
}
}
q.init();
q.start();
fMain.add("Center", q);
MenuBar menu = new MenuBar();
Menu file = new Menu("File");
file.add("Exit");
file.addActionListener(q);
menu.add(file);
fMain.setMenuBar(menu);
fMain.setSize(500, 400);
fMain.show();
fMain.addWindowListener(q);
}
示例10: addMenuItems
import java.awt.Menu; //導入方法依賴的package包/類
/**
* Method declaration
*
*
* @param f
* @param m
*/
void addMenuItems(Menu f, String m[]) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
示例11: addMenuItems
import java.awt.Menu; //導入方法依賴的package包/類
/**
* Method declaration
*
*
* @param f
* @param m
*/
private void addMenuItems(Menu f, String m[]) {
for (int i = 0; i < m.length; i++) {
if (m[i].equals("-")) {
f.addSeparator();
} else {
MenuItem item = new MenuItem(m[i]);
item.addActionListener(this);
f.add(item);
}
}
}
示例12: main
import java.awt.Menu; //導入方法依賴的package包/類
/**
* Method declaration
*
*
* @param arg
*/
public static void main(String arg[]) {
fMain = new Frame("Query Tool");
QueryTool q = new QueryTool();
q.bApplication = true;
for (int i = 0; i < arg.length; i++) {
String p = arg[i];
if (p.equals("-?")) {
printHelp();
}
if (p.charAt(0) == '-') {
pProperties.put(p.substring(1), arg[i + 1]);
i++;
}
}
q.init();
q.start();
fMain.add("Center", q);
MenuBar menu = new MenuBar();
Menu file = new Menu("File");
file.add("Exit");
file.addActionListener(q);
menu.add(file);
fMain.setMenuBar(menu);
fMain.setSize(500, 400);
fMain.show();
fMain.addWindowListener(q);
}
示例13: ActionEventTest
import java.awt.Menu; //導入方法依賴的package包/類
public ActionEventTest() {
menuBar = new MenuBar();
Menu menu = new Menu("Menu1");
MenuItem menuItem = new MenuItem("MenuItem");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
System.out.println("actionPerformed");
int md = ae.getModifiers();
int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
| ActionEvent.SHIFT_MASK;
isProgInterruption = true;
mainThread.interrupt();
if ((md & expectedMask) != expectedMask) {
throw new RuntimeException("Action Event modifiers are not"
+ " set correctly.");
}
}
});
menu.add(menuItem);
menuBar.add(menu);
setMenuBar(menuBar);
instructions = new TextArea(10, 50);
instructions.setText(
" This is a manual test\n" +
" Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
" Click 'Menu1' Menu from the Menu Bar\n" +
" It will show 'MenuItem'\n" +
" Left mouse Click the 'MenuItem'\n" +
" Test exits automatically after mouse click.");
add(instructions);
setSize(400, 400);
setVisible(true);
validate();
}
示例14: createMenuBar
import java.awt.Menu; //導入方法依賴的package包/類
private MenuBar createMenuBar(Container contentPane) {
menubar = new MenuBar();
menu = new Menu();
menu.setLabel("Action");
menuItem = new MenuItem();
menuItem.setLabel("Append");
menu.add(menuItem);
menubar.add(menu);
return menubar;
}
示例15: addAudioInputs
import java.awt.Menu; //導入方法依賴的package包/類
private void addAudioInputs( Menu menu )
{
SelectInput select_input = SelectInput.getInstance();
RadioMenuItemGroup input_group = new RadioMenuItemGroup();
for ( int i = 0; i < select_input.getInputs().length; i++ )
{
boolean state = false;
if ( select_input.getInputs()[i].getName().equals( "Soundflower (2ch)" ) )
{
state = true;
}
final int index = i;
RadioMenuItem audio_option = new RadioMenuItem(
select_input.getInputs()[i].getName(), input_group, state );
audio_option.addItemListener( new ItemListener()
{
@Override
public void itemStateChanged( ItemEvent e )
{
if ( e.getStateChange() == ItemEvent.SELECTED )
{
new Message( "Switching inputs to " + SelectInput
.getInstance().getInputs()[index].getName() +
"\nThis is an experimental feature." );
SelectInput.getInstance().refresh();
in.close();
in = SelectInput.getInstance().setInput(
SelectInput.getInstance().getInputs()[index] );
}
}
});
menu.add( audio_option );
}
}