200分求怎么SWT实现置顶消息滚动
不够开新帖给分
要求在SWT窗体顶部实现滚动消息。

解决方案 »

  1.   

    用SWT的菜单可以模拟实现import java.util.Random;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.SashForm;
    import org.eclipse.swt.custom.ScrolledComposite;
    import org.eclipse.swt.dnd.DND;
    import org.eclipse.swt.dnd.DropTarget;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.CoolBar;
    import org.eclipse.swt.widgets.CoolItem;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Link;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.MenuItem;
    import org.eclipse.swt.widgets.MessageBox;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Table;
    import org.eclipse.swt.widgets.ToolBar;
    import org.eclipse.swt.widgets.ToolItem;
    import com.swtdesigner.SWTResourceManager;public class x {
    protected Shell shell;
    int n=1;
    boolean bz = false;
    MenuItem msn;
    /**
     * Launch the application
     * @param args
     */
    public static void main(String[] args) {
    try {
    x window = new x();
    window.open();
    } catch (Exception e) {
    e.printStackTrace();
    }
    } /**
     * Open the window
     */
    public void open() {
    final Display display = Display.getDefault();
    createContents();
    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
    display.sleep();
    }
    } /**
     * Create contents of the window
     */
    protected void createContents() {
    shell = new Shell();
    shell.setSize(500, 375);
    shell.setText("SWT Application"); final Menu menu = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menu); final MenuItem menuItem = new MenuItem(menu, SWT.CASCADE);
    menuItem.setText("Menu item"); final Menu menu_1 = new Menu(menuItem);
    menuItem.setMenu(menu_1); final MenuItem menuItem_1 = new MenuItem(menu_1, SWT.NONE);
    menuItem_1.setText("Menu item"); msn = new MenuItem(menu, SWT.NONE);
    msn.setSelection(true);
    msn.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(final SelectionEvent e) {
    MessageBox msgbox = new MessageBox(shell);
    msgbox.setText("测试");
    msgbox.setMessage(msn.getText());
    msgbox.open();
    }
    });
    msn.setText("men"); final Button button = new Button(shell, SWT.NONE);
    button.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(final SelectionEvent e) {
    new Thread() {
    public void run() {
    while(true) {
    SetMessage(System.currentTimeMillis());
    try {
    Thread.sleep(500);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }

    }
    }.start();
    }
    });
    button.setText("button");
    button.setBounds(71, 129, 120, 30); }

    void SetMessage(final Long msg) {
    Display.getDefault().syncExec(new Runnable() {
    public void run() {
    msn.setText("最新消息编号:"+Long.toString(msg));
    Random rad=new Random(msg);
    int n = rad.nextInt();
    n = Math.abs(n  %  10);
    msn.setImage(SWTResourceManager.getImage(x.class, n+".png"));
    }
    });
    }
    }
      

  2.   

    http://community.csdn.net/Expert/topic/4755/4755481.xml?temp=2.465457E-02
    另外100分