Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » [REPOST] Maybe List control bug ?
[REPOST] Maybe List control bug ? [message #458797] Thu, 21 July 2005 15:47 Go to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I have two list controls on a sashform and I want to show the selected item
even after the list control is resized. I've added a resize listener to both
list control and called showSelection() method. In some situation the list
items are doubled, see attached image.


import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;


/**
* @author Robert Bacs
*/
public class ListTest {
public static void main (String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

SashForm sashForm = new SashForm(shell, SWT.VERTICAL);

final List list1 = new List(sashForm, SWT.BORDER | SWT.H_SCROLL |
SWT.V_SCROLL);
for (int i = 1; i <= 10; i++){
list1.add("Item" + i);
}
list1.addListener(SWT.Resize, new Listener(){
public void handleEvent(Event event) {
list1.showSelection();
list1.update();
}
});
List list2 = new List(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
for (int i = 1; i <= 10; i++){
list2.add("Item" + i);
}

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


  • Attachment: picture.jpg
    (Size: 9.70KB, Downloaded 103 times)
Re: [REPOST] Maybe List control bug ? [message #459156 is a reply to message #458797] Tue, 02 August 2005 18:22 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=104992

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:dbog2i$thk$1@news.eclipse.org...
> Hi,
>
> I have two list controls on a sashform and I want to show the selected
item
> even after the list control is resized. I've added a resize listener to
both
> list control and called showSelection() method. In some situation the list
> items are doubled, see attached image.
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.SashForm;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.List;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Shell;
>
>
> /**
> * @author Robert Bacs
> */
> public class ListTest {
> public static void main (String [] args) {
> final Display display = new Display ();
> final Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
>
> SashForm sashForm = new SashForm(shell, SWT.VERTICAL);
>
> final List list1 = new List(sashForm, SWT.BORDER | SWT.H_SCROLL |
> SWT.V_SCROLL);
> for (int i = 1; i <= 10; i++){
> list1.add("Item" + i);
> }
> list1.addListener(SWT.Resize, new Listener(){
> public void handleEvent(Event event) {
> list1.showSelection();
> list1.update();
> }
> });
> List list2 = new List(sashForm, SWT.BORDER | SWT.H_SCROLL |
SWT.V_SCROLL);
> for (int i = 1; i <= 10; i++){
> list2.add("Item" + i);
> }
>
> shell.pack ();
> shell.open ();
> shell.layout();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
>
>
Previous Topic:Customizing table
Next Topic:Ole + Acrobat = NPE
Goto Forum:
  


Current Time: Tue Oct 27 15:38:41 GMT 2020

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

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

Back to the top