Windows 7 SWT Combo box issue [message #705493] |
Fri, 29 July 2011 23:55 |
Santhosh Missing name Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Hi All,
I am facing an issue with the SWT Combo in my eclipse RCP application.
I will try explaining my issue with a use case for better understanding.
1. I have a combo box in a Eclipse RCP View with values say "A", "B","C","D" and i have a submit button beside it & a SWT table right below it.
2. Once the value is changed in the Combo and submit button is clicked, records would be displayed in the table.
3. Let us suppose "A" is selected by default and records of A are displayed in the table on view invocation.
4. Now I select "B" from the drop down and click submit. I see only the records of "A" in the table although the combo shows "B".
5. ONLY if I select "B" again from the combo and then click submit, "B"'s records gets displayed.
6. Now if I select C from the combo , only "B"'s records gets displayed.
7. Later, If i select D from the Combo , "C"'s records are displayed.
It seems that only the previous selections is processed and displayed rather than the current selection.
I am not facing this issue in Windows XP or prev versions of windows. I recently shifted to Windows 7 64-bit OS where I faced this issue.
Is this a known issue? Any help would be appreciated.
Thanks,
Santhosh
|
|
|
|
Re: Windows 7 SWT Combo box issue [message #709350 is a reply to message #708373] |
Wed, 03 August 2011 20:53 |
Santhosh Missing name Messages: 12 Registered: July 2009 |
Junior Member |
|
|
sure. here is an example. I am printing the index of the selected index on click of Submit. Please try out the example in Windows 7
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
public class TestCombo {
private static String[] filterByText = new String[] {"A","B","C","D"};
static int index = 0;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Composite comp = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
GridData gridData = new GridData(SWT.FILL,SWT.FILL,true,false);
comp.setLayout(layout);
comp.setLayoutData(gridData);
final Combo filter = new Combo (comp, SWT.READ_ONLY);
filter.setItems (filterByText );
filter.setText (filterByText[0]);
filter.setVisibleItemCount( filterByText.length );
filter.addListener(SWT.DROP_DOWN, new Listener() {
@Override
public void handleEvent(Event event) {
index = filter.getSelectionIndex();
}
});
Button submit = new Button (comp, SWT.PUSH);
submit.setText ("Submit");
GridData data = new GridData();
data.widthHint = 80;
submit.setLayoutData(data);
submit.addSelectionListener (new SelectionAdapter () {
public void widgetSelected(SelectionEvent e) {
System.out.println("The index is ==> "+index);
}
});
comp.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|
|
|
Re: Windows 7 SWT Combo box issue [message #709673 is a reply to message #709350] |
Thu, 04 August 2011 06:52 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
The listener with SWT.DROP_DOWN is wrong and you should use SWT.Selection.
Tom
Am 03.08.11 22:53, schrieb Santhosh:
> sure. here is an example. I am printing the index of the selected index
> on click of Submit. Please try out the example in Windows 7
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Combo;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Shell;
>
>
> public class TestCombo {
>
>
> private static String[] filterByText = new String[] {"A","B","C","D"};
> static int index = 0;
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
>
>
> Composite comp = new Composite(shell, SWT.NONE);
> GridLayout layout = new GridLayout(2, false);
> GridData gridData = new GridData(SWT.FILL,SWT.FILL,true,false);
> comp.setLayout(layout);
> comp.setLayoutData(gridData);
>
> final Combo filter = new Combo (comp, SWT.READ_ONLY);
> filter.setItems (filterByText );
> filter.setText (filterByText[0]);
> filter.setVisibleItemCount( filterByText.length );
> filter.addListener(SWT.DROP_DOWN, new Listener() {
>
> @Override
> public void handleEvent(Event event) {
> index = filter.getSelectionIndex();
>
> }
> });
>
> Button submit = new Button (comp, SWT.PUSH);
> submit.setText ("Submit");
> GridData data = new GridData();
> data.widthHint = 80;
> submit.setLayoutData(data);
> submit.addSelectionListener (new SelectionAdapter () {
> public void widgetSelected(SelectionEvent e) {
>
> System.out.println("The index is ==> "+index);
> }
> });
> comp.pack();
> shell.pack();
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> }
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04150 seconds