Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Windows 7 SWT Combo box issue(Windows 7 SWT Combo box issue)
Windows 7 SWT Combo box issue [message #705493] Fri, 29 July 2011 19:55 Go to next message
Eclipse UserFriend
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 #708373 is a reply to message #705493] Tue, 02 August 2011 14:50 Go to previous messageGo to next message
Eclipse UserFriend
As it is not working only on Windows 7 it may be a bug.
Can you provide an example snippet/sample code to show the problem?
Re: Windows 7 SWT Combo box issue [message #709350 is a reply to message #708373] Wed, 03 August 2011 16:53 Go to previous messageGo to next message
Eclipse UserFriend
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 02:52 Go to previous messageGo to next message
Eclipse UserFriend
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();
> }
>
> }
>
Re: Windows 7 SWT Combo box issue [message #710090 is a reply to message #709673] Thu, 04 August 2011 13:35 Go to previous messageGo to next message
Eclipse UserFriend
But, SWT.DROP_DOWN is what i have been using till we migrated to Windows 7. The same code works as expected in the previous version of Windows. Has there been any changes related to SWT.DROP_DOWN in windows 7? Has the use of SWT.DROP_DOWN been deprecated?
Re: Windows 7 SWT Combo box issue [message #710102 is a reply to message #710090] Thu, 04 August 2011 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Please read the JavaDoc for SWT.DROP_DOWN. It has never been meant to be
used for listeners! Does it work with SWT.Selection?

Tom

Am 04.08.11 19:35, schrieb Santhosh:
> But, SWT.DROP_DOWN is what i have been using till we migrated to Windows
> 7. The same code works as expected in the previous version of Windows.
> Has there been any changes related to SWT.DROP_DOWN in windows 7? Has
> the use of SWT.DROP_DOWN been deprecated?
>
Re: Windows 7 SWT Combo box issue [message #710235 is a reply to message #710102] Thu, 04 August 2011 16:58 Go to previous message
Eclipse UserFriend
Yes. It works with SWT.Selection.
Thanks a lot Smile
Previous Topic:SWT Browser doesn't always paint
Next Topic:OS X: avoid blue border around tree or tables
Goto Forum:
  


Current Time: Thu Jul 10 02:30:42 EDT 2025

Powered by FUDForum. Page generated in 0.06314 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top