我有我在网格布局中显示的项目列表。 每一行有几个图像按钮。 当行数超过1000达到我越来越org.eclipse.swt.SWTError: No more handles
异常。
我用Sleak.java
,发现里面已经有一些在存储的图像。 是否有可能以某种方式重新使用这些按钮?
下面是从统计Sleak
。
颜色:8个光标:6种字体:19张图片:1317
码:
private void looper(List<File> dicomFiles, int start, int stop, int toShow){
for(int i=start; i<stop; i++){
File dicomFile = dicomFiles.get(i);
Composite rowComposite = new Composite(dicomFilecomposite, SWT.None);
rowComposite.setLayout(configRowCompositeLayout());
rowComposite.setLayoutData(getRowCompositeGridData());
rowComposite.setBackground(Colors.CELL_BG_COLOR);
Label dicomFIleLabel = new Label(rowComposite, SWT.NULL);
dicomFIleLabel.setLayoutData(new GridData());
dicomFIleLabel.setText(dicomFile.getName());
dicomFIleLabel.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
dicomFIleLabel.setFont(FONT_10);
Label fileSizeLabel = new Label(rowComposite, SWT.None);
fileSizeLabel.setText((dicomFile.length() / 1000)+" "+Const.KB_LABEL);
fileSizeLabel.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
Composite progBarLabelComposite = new Composite(rowComposite, SWT.None);
progBarLabelComposite.setLayout(new RowLayout());
ProgressBar progressBar = new ProgressBar(progBarLabelComposite, SWT.HORIZONTAL | SWT.SMOOTH);
progressBar.setVisible(true);
Label progressPercentageLabel = new Label(progBarLabelComposite, SWT.None);
progressPercentageLabel.setText(Const.INITIAL_PROGBAR_PERCENTAGE);
progressPercentageLabel.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
Composite btnWrapperComposite = new Composite(rowComposite, SWT.None);
btnWrapperComposite.setLayout(configZeroMarginLayout(true));
GridData btnWrapperCompositeGridData = new GridData();
btnWrapperCompositeGridData.horizontalAlignment = GridData.END;
btnWrapperCompositeGridData.grabExcessHorizontalSpace = true;
btnWrapperComposite.setLayoutData(btnWrapperCompositeGridData);
Composite uploadCancelBtnComposite = new Composite(btnWrapperComposite, SWT.None);
uploadCancelBtnComposite.setLayout(new RowLayout());
Composite uploadBtnComposite = new Composite(uploadCancelBtnComposite, SWT.NULL);
uploadBtnComposite.setLayout(configZeroMarginLayout(false));
ImageButton uploadButton = new ImageButton(uploadBtnComposite, SWT.PUSH);
uploadButton.setImage(Const.UPLOAD_BTN_BG_IMAGE);
uploadButton.setListener(MainShell.this);
uploadButton.setCursor(HAND_CURSOR);
uploadButton.setToolTipText(Const.UPLOAD_LABEL);
ImageButton cancelButton = new ImageButton(uploadCancelBtnComposite, SWT.PUSH);
cancelButton.setImage(Const.DELETE_BTN_BG_IMAGE);
cancelButton.setListener(MainShell.this);
cancelButton.setCursor(HAND_CURSOR);
cancelButton.setToolTipText(Const.DELETE_LABEL);
FileUploadData fileUploadData = loadFileUploadData(progBarLabelComposite, dicomFilecomposite, dicomFile, progressBar, progressPercentageLabel);
uploadButton.setData(fileUploadData);
uploadButton.setData(IMG_BTN_DATA_KEY, Const.UPLOAD_LABEL);
uploadButtons.add(uploadButton);
fileUploadDatas.add(fileUploadData);
cancelButton.setData(fileUploadData);
cancelButton.setData(IMG_BTN_DATA_KEY, Const.DELETE_LABEL);
loadSeparatorField(rowComposite);
}
}
在这两条线在哪里这个问题在我的理解中发生。
ImageButton uploadButton = new ImageButton(uploadBtnComposite, SWT.PUSH);
ImageButton cancelButton = new ImageButton(uploadCancelBtnComposite, SWT.PUSH);