Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350879 - setSelection for radio button does not work
Summary: setSelection for radio button does not work
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-30 15:32 EDT by Keith Willenson CLA
Modified: 2020-03-26 18:35 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Willenson CLA 2011-06-30 15:32:49 EDT
Build Identifier: I20110613-1736

No matter which radio button has setSelection(true), the first button always is selected.

Reproducible: Always

Steps to Reproduce:
    int radiusRounding = 2;

    for (int i=0;i<=3;i++)
    {
      String value = "Button " + Integer.toString(i);
      Button b = new Button(entryComp, SWT.RADIO);
      b.setText(value);
      b.setSelection(i == radiusRounding);
    }
Comment 1 Felipe Heidrich CLA 2011-07-05 10:51:50 EDT
works for me:
public static void main(String[] args) {
	Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout());
	int radiusRounding = 2;
	for (int i = 0; i <= 3; i++) {
		String value = "Button " + Integer.toString(i);
		Button b = new Button(shell, SWT.RADIO);
		b.setText(value);
		b.setSelection(i == radiusRounding);
	}
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
	display.dispose();
}

can you please try this above?
I running SWT from head:
http://eclipse.org/swt/cvs.php
Comment 2 Shiluka Dharmasena CLA 2014-03-03 11:48:37 EST
it works on linux and windows

Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout());

		Button b1 = new Button(shell, SWT.RADIO);
		b1.setText("button_1");

		Button b2 = new Button(shell, SWT.RADIO);
		b2.setText("button_2");

		Button b3 = new Button(shell, SWT.RADIO);
		b3.setText("button_3");

		b2.setSelection(true);

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
Comment 3 Shiluka Dharmasena CLA 2014-03-03 11:54:28 EST
it works on linux and windows

                Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout());

		Button b1 = new Button(shell, SWT.RADIO);
		b1.setText("button_1");

		Button b2 = new Button(shell, SWT.RADIO);
		b2.setText("button_2");

		Button b3 = new Button(shell, SWT.RADIO);
		b3.setText("button_3");

		b2.setSelection(true);

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();


what is the OS you used ?
Comment 4 Eclipse Genie CLA 2020-03-26 18:35:16 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.