本文整理匯總了Java中org.eclipse.swt.widgets.MenuItem.setMenu方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setMenu方法的具體用法?Java MenuItem.setMenu怎麽用?Java MenuItem.setMenu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setMenu方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createViewMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private Menu createViewMenu() {
final MenuItem mi = new MenuItem(menuBar, SWT.CASCADE);
mi.setText("&View");
final Menu m = new Menu(shell, SWT.DROP_DOWN);
mi.setMenu(m);
SWTUtils.addMenuItem(m, "Increase Font Size", SWT.CTRL + '+', () -> {
setFontSize(fontSize + 1);
});
SWTUtils.addMenuItem(m, "Decrease Font Size", SWT.CTRL + '-', () -> {
setFontSize(fontSize - 1);
});
return m;
}
示例2: createAlbaumMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private Menu createAlbaumMenu() {
final MenuItem mi = new MenuItem(menuBar, SWT.CASCADE);
mi.setText("&Albaum");
final Menu m = new Menu(shell, SWT.DROP_DOWN);
mi.setMenu(m);
SWTUtils.addMenuItem(m, "E&xit", SWT.SHIFT + SWT.CTRL + 'X', () -> {
isExiting = true;
});
return m;
}
示例3: setMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public static void setMenu(final MenuItem menuItem, final Menu subMenu)
{
if (Thread.currentThread() != getDisplay().getThread())
{
getDisplay().syncExec(new Runnable() {public void run() {setMenu(menuItem, subMenu);}});
}
else
{
menuItem.setMenu(subMenu);
}
}
示例4: createContents
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
/**
* Create contents of the window.
*/
protected void createContents() {
shlContacts = new Shell();
shlContacts.setSize(200, 400);
shlContacts.setText("Contacts");
Menu menu = new Menu(shlContacts, SWT.BAR);
shlContacts.setMenuBar(menu);
MenuItem mntmControl = new MenuItem(menu, SWT.CASCADE);
mntmControl.setText("dev_options");
Menu menu_1 = new Menu(mntmControl);
mntmControl.setMenu(menu_1);
MenuItem mntmdevrescan = new MenuItem(menu_1, SWT.NONE);
mntmdevrescan.setText("(dev)_rescan");
table = new Table(shlContacts, SWT.BORDER | SWT.FULL_SELECTION);
table.setBounds(0, 0, 194, 298);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tblclmnAvailableContacts = new TableColumn(table, SWT.NONE);
tblclmnAvailableContacts.setResizable(false);
tblclmnAvailableContacts.setWidth(100);
tblclmnAvailableContacts.setText("Available Contacts:");
Button btnConnect = new Button(shlContacts, SWT.NONE);
btnConnect.setBounds(10, 309, 174, 27);
btnConnect.setText("CONNECT");
}
示例5: createCascadeMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
CascadeMenu createCascadeMenu(Menu parent, Image img, String txt) {
MenuItem mi = createItem(parent, SWT.CASCADE, img, txt);
Menu m = new Menu(mi);
mi.setMenu(m);
return new CascadeMenu(m, mi);
}
示例6: createSubMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
Menu createSubMenu(Menu parentMenu, String text) {
MenuItem mi = new MenuItem(menu, SWT.CASCADE);
mi.setText(text);
Menu m = new Menu(parentMenu);
mi.setMenu(m);
return m;
}
示例7: viewMenu
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void viewMenu() {
MenuItem view = new MenuItem(shell.getMenuBar() == null ? Display.getDefault().getMenuBar() : shell.getMenuBar(), SWT.CASCADE);
view.setText("&View");
Menu viewmenu = new Menu(shell, SWT.DROP_DOWN);
view.setMenu(viewmenu);
addItem(viewmenu, engine, 'E');
if(push != null)
addItem(viewmenu, push, 'D');
addItem(viewmenu, resman, 'R');
}
示例8: MenuClass
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public MenuClass() {
display = new Display();
shell = new Shell(display);
shell.setText("Menu Example");
shell.setSize(300, 200);
text = new Text(shell, SWT.BORDER);
text.setBounds(80, 50, 150, 25);
menuBar = new Menu(shell, SWT.BAR);
fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
fileMenuHeader.setText("&File");
fileMenu = new Menu(shell, SWT.DROP_DOWN);
fileMenuHeader.setMenu(fileMenu);
fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
fileSaveItem.setText("&Save");
fileEnglishItem = new MenuItem(fileMenu, SWT.RADIO);
fileEnglishItem.setText("English");
fileGermanItem = new MenuItem(fileMenu, SWT.RADIO);
fileGermanItem.setText("German");
fileExitItem = new MenuItem(fileMenu, SWT.PUSH);
fileExitItem.setText("E&xit");
editMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
editMenuHeader.setText("&Edit");
editMenu = new Menu(shell, SWT.DROP_DOWN);
editMenuHeader.setMenu(editMenu);
editCopyItem = new MenuItem(editMenu, SWT.PUSH);
editCopyItem.setText("&Copy");
fileExitItem.addSelectionListener(new MenuItemListener());
fileSaveItem.addSelectionListener(new MenuItemListener());
editCopyItem.addSelectionListener(new MenuItemListener());
fileEnglishItem.addSelectionListener(new RadioItemListener());
fileGermanItem.addSelectionListener(new RadioItemListener());
shell.setMenuBar(menuBar);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}