Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Too many ToolItems bug


I have found that when I create a certain number of ToolItems in a Toolbar they will not display. I am compiling and running my code on a mac, OSX 10.4.10, JVM 1.5, with eclipse/SWT 3.2. In the code below if you set the COUNT variable to 310 or lower, you will see the toolitems display correctly - but if you set the COUNT to 311 or higher then you will not see the toolitems at all. I have not stepped into the SWT source to see what is going on, anyone have any ideas ?

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ToolbarTest
{
        private static final int SIZE = 100;
       
        private static final int COUNT = 310;
       
        public static void main (String [] args)
        {
                Display display = new Display();
                Shell shell = new Shell(display);
                Image image = new Image (display, SIZE, SIZE);
                shell.setLayout(new FillLayout());                
                ToolBar bar = new ToolBar (shell, SWT.HORIZONTAL);        
         
                for (int i=0; i<COUNT; i++)
                {
                        ToolItem item = new ToolItem(bar, SWT.NONE);
                        item.setImage (image);
                }
         
                Point point = bar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                bar.setSize(point);
                shell.open();
       
                while (!shell.isDisposed ())
                {
                        if (!display.readAndDispatch ())
                        {
                                display.sleep();
                        }
                }
               
                image.dispose();                
                display.dispose();
        }
}

Back to the top