-4
我想將圖像設置爲工具項目。但是,我的程序不起作用,它只是顯示一個空的窗口。將圖像添加到工具項目
我迄今爲止代碼:
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
public class test
{
public static void main(String [] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(900, 200);
final ToolBar t=new ToolBar(shell,SWT.NONE);
Image image=new Image(display,"C:\\Users\\ART\\Documents\\Parsian\\bottum.jpg");
final ToolItem ti=new ToolItem(t,SWT.NONE);
ti.setImage(image);
ti.setText("test");
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}