如果软件开发界面中的工具栏中只有一两个图片,这种直接创建图片对象然后释放的办法是可行的,但当图片增多时也要一个一个地创建和释放吗?可想而知,代码将变得复杂,所以有必要将图片的管理集中到一起,进行统一的管理.
main方法:
main方法:
package
sxjm;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets. * ;
import swtDemo.ImageFactory;
public class ToolBarSample {
public static void main(String args[])
{
Display d = new Display();
Shell s = new Shell(d);
s.setLayout(new GridLayout());
Composite tool = new Composite(s,SWT.NONE);
tool.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,false));
ToolBar toolBar = new ToolBar(tool,SWT.NONE);
ToolItem saveItem = new ToolItem(toolBar,SWT.PUSH);
saveItem.setImage(ImageFactory.loadImage(d,ImageFactory.SAVE_EDIT));
saveItem.setText("save
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets. * ;
import swtDemo.ImageFactory;
public class ToolBarSample {
public static void main(String args[])
{
Display d = new Display();
Shell s = new Shell(d);
s.setLayout(new GridLayout());
Composite tool = new Composite(s,SWT.NONE);
tool.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,false));
ToolBar toolBar = new ToolBar(tool,SWT.NONE);
ToolItem saveItem = new ToolItem(toolBar,SWT.PUSH);
saveItem.setImage(ImageFactory.loadImage(d,ImageFactory.SAVE_EDIT));
saveItem.setText("save