package com.swtjface.Ch2;import org.eclipse.swt.*;import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;import org.eclipse.jface.window.*;public class WidgetWindow extends ApplicationWindow { public WidgetWindow() { super(null); } protected Control createContents(Composite parent) { parent.setLayout(new GridLayout());

TabFolder tf = new TabFolder(parent, SWT.NONE);

tf.setLayoutData(new GridData(400,300));



TabItem M2000 = new TabItem(tf, SWT.NONE);

TabItem OSMU = new TabItem(tf, SWT.NONE); Composite composite = new Composite(tf, 0);

composite.setLayout(new GridLayout()); Button button = new Button(composite, SWT.BORDER);

button.setText("查询");

OSMU.setText("OSMU"); M2000.setText("M200");

OSMU.setControl(composite); M2000.setControl(composite); getShell().setText("OSMU"); return parent; } public static void main(String[] args) { WidgetWindow wwin = new WidgetWindow(); wwin.setBlockOnOpen(true); wwin.open(); Display.getCurrent().dispose(); }}

解决方案 »

  1.   

    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.TabFolder;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.TabItem;
    import org.eclipse.swt.widgets.Text;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Button;public class Test {
    private static Text text; /**
     * Launch the application.
     * 
     * @param args
     */
    public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("SWT Application"); TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
    tabFolder.setBounds(10, 0, 422, 256); TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText("New Item"); text = new Text(tabFolder, SWT.BORDER);
    tabItem.setControl(text); TabItem tabItem_2 = new TabItem(tabFolder, SWT.NONE);
    tabItem_2.setText("New Item"); Button button = new Button(tabFolder, SWT.NONE);
    tabItem_2.setControl(button);
    button.setText("New Button"); TabItem tabItem_1 = new TabItem(tabFolder, SWT.NONE);
    tabItem_1.setText("New Item"); Label label = new Label(tabFolder, SWT.NONE);
    tabItem_1.setControl(label);
    label.setText("New Label"); shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
    display.sleep();
    }
    }
    }
    }
      

  2.   

    package com.huawei.bz2;import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;public class ZIP {
    public void getZip(List list, String path, String fileName)
    throws Exception {
    byte[] buffer = new byte[1024]; String strZipName = fileName + ".zip";
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(path
    + strZipName));
    for (int j = 0; j < list.size(); j++) {
    String name = list.get(j).toString(); FileInputStream fis = new FileInputStream(path + name);
    out.putNextEntry(new ZipEntry(name));
    int len;
    while ((len = fis.read(buffer)) > 0) {
    out.write(buffer, 0, len);
    }
    out.closeEntry();
    out.finish();
    fis.close(); }
    out.close();
    System.out.println("生成Demo.zip成功");
    } public static void main(String[] args) {
    ZIP bz2 = new ZIP();
    List list = new ArrayList();
    list.add("springIOC.txt"); String path = "e://学习资料/";
    String fileName = "springIOC.txt";
    try {
    bz2.getZip(list, path, fileName);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }