List control problem [message #458638] |
Mon, 18 July 2005 06:38 |
Eclipse User |
|
|
|
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 235 times)
|
|
|
Powered by
FUDForum. Page generated in 0.03713 seconds