Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 264376 Details for
Bug 502056
[GTK] [Ubuntu] Radio button menu item does not change selection state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Sample code to reproduce
RadioButtonMenuItemTest.java (text/plain), 1.98 KB, created by
Thomas Singer
on 2016-09-23 07:40:35 EDT
(
hide
)
Description:
Sample code to reproduce
Filename:
MIME Type:
Creator:
Thomas Singer
Created:
2016-09-23 07:40:35 EDT
Size:
1.98 KB
patch
obsolete
>import java.util.*; >import java.util.List; > >import org.eclipse.swt.*; >import org.eclipse.swt.widgets.*; > >/** > * @author Thomas Singer > */ >public class RadioButtonMenuItemTest { > > public static void main(String[] args) { > final Display display = new Display(); > final Shell shell = new Shell(display); > final Menu bar = new Menu(shell, SWT.BAR); > shell.setMenuBar(bar); > final MenuItem fileItem = new MenuItem(bar, SWT.CASCADE); > fileItem.setText("&File"); > final Menu submenu = new Menu(shell, SWT.DROP_DOWN); > fileItem.setMenu(submenu); > > new MenuItem(submenu, SWT.PUSH).setText("Hello"); > > final List<MenuItem> radioMenuItems = new ArrayList<>(); > final MenuItem firstItem = createRadioMenuItem("Value 1", submenu, radioMenuItems); > createRadioMenuItem("Value 2", submenu, radioMenuItems); > createRadioMenuItem("Value 3", submenu, radioMenuItems); > > setSelection(firstItem, radioMenuItems); > > new MenuItem(submenu, SWT.PUSH).setText("World"); > > shell.setSize(200, 200); > > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > display.dispose(); > } > > private static MenuItem createRadioMenuItem(String text, Menu menu, final List<MenuItem> radioMenuItems) { > final MenuItem menuItem = new MenuItem(menu, SWT.RADIO); > menuItem.setText(text); > radioMenuItems.add(menuItem); > menuItem.addListener(SWT.Selection, new Listener() { > @Override > public void handleEvent(Event e) { > setSelection((MenuItem)e.widget, radioMenuItems); > } > }); > return menuItem; > } > > private static void setSelection(MenuItem itemToSelect, List<MenuItem> radioMenuItems) { > for (MenuItem item : radioMenuItems) { > item.setSelection(item == itemToSelect); > } > /* > for (MenuItem item : radioMenuItems) { > if (item == itemToSelect) { > item.setSelection(true); > } > } > > for (MenuItem item : radioMenuItems) { > final boolean selection = item == itemToSelect; > if (item.getSelection() != selection) { > item.setSelection(selection); > } > } > */ > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 502056
: 264376