本文整理匯總了Java中org.eclipse.swt.widgets.MenuItem.getSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.getSelection方法的具體用法?Java MenuItem.getSelection怎麽用?Java MenuItem.getSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.MenuItem
的用法示例。
在下文中一共展示了MenuItem.getSelection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMenuItem
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(Menu menu, BookmarkId selectedBookmarkId, BookmarkNumber bookmarkNumber) {
Optional<BookmarkId> bookmarkId = numberedBookmarks.getBookmark(bookmarkNumber);
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
menuItem.setSelection(bookmarkId.isPresent() ? bookmarkId.get().equals(selectedBookmarkId) : false);
menuItem.setText(getText(bookmarkId));
menuItem.setAccelerator('0' + bookmarkNumber.getNumber());
Image image = getImage(bookmarkNumber, bookmarkId);
if (image != null) {
menuItem.setImage(image);
}
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
switch (event.type) {
case SWT.Selection:
if (menuItem.getSelection()) {
bookmarksService.addNumberedBookmark(selectedBookmarkId, bookmarkNumber);
}
break;
}
}
};
menuItem.addListener(SWT.Selection, listener);
}
示例2: ATranscriptionWidgetListener
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public ATranscriptionWidgetListener(TrpMainWidget mainWidget, ATranscriptionWidget transcriptionWidget) {
this.mainWidget = mainWidget;
this.transcriptionWidget = transcriptionWidget;
transcriptionWidget.addListener(SWT.FocusIn, this);
transcriptionWidget.addListener(SWT.Selection, this);
transcriptionWidget.addListener(SWT.DefaultSelection, this);
transcriptionWidget.addListener(SWT.Modify, this);
// transcriptionWidget.addListener(SWT.KeyDown, listener);
transcriptionWidget.getText().addKeyListener(this);
transcriptionWidget.getVkItem().addListener(SWT.Selection, this);
// listener for change of transcription widget type:
SelectionAdapter transcriptTypeListener = new SelectionAdapter() {
@Override public void widgetSelected(SelectionEvent e) {
if (!(e.getSource() instanceof MenuItem))
return;
MenuItem mi = (MenuItem) e.getSource();
if (mi.getSelection()) {
mainWidget.getUi().changeToTranscriptionWidget((TranscriptionLevel) mi.getData());
}
}
};
transcriptionWidget.getTranscriptionTypeLineBasedItem().addSelectionListener(transcriptTypeListener);
transcriptionWidget.getTranscriptionTypeWordBasedItem().addSelectionListener(transcriptTypeListener);
// transcriptionWidget.getTranscriptionTypeItem().ti.addSelectionListener(new SelectionAdapter() {
// @Override public void widgetSelected(SelectionEvent e) {
// if (e.detail != SWT.ARROW) {
// ATranscriptionWidget.Type type = (Type) transcriptionWidget.getTranscriptionTypeItem().getSelected().getData();
// mainWidget.getUi().changeToTranscriptionWidget(type);
// }
// }
// });
}
示例3: getSelectedIndices
import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
/** The indices of all the items that are selected. */
public List<Integer> getSelectedIndices() {
List<Integer> selected = new ArrayList<>();
int i=0;
for (MenuItem mi : listener.menu.getItems()) {
if (mi.getSelection()) {
selected.add(i);
}
++i;
}
return selected;
}