Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » List control problem
List control problem [message #458638] Mon, 18 July 2005 10:38
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 195 times)
Previous Topic:Getting to an embedded AWT object from the SWT hierarchy
Next Topic:SWT Print - Hide Fila Dialog
Goto Forum:
  


Current Time: Wed Oct 28 21:08:14 GMT 2020

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

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

Back to the top