怎样实现鼠标点击在"申请帐号"和"忘了密码"上使字的颜色改变和鼠标变为手型了 
"申请帐号"是用什么组件做的?

解决方案 »

  1.   

    对按钮使用事件,mouseEnter事件,当鼠标进入按钮后,对字体和鼠标形状进行设置
      

  2.   


    /*
     * Created on Oct 16,2008
     * 
     * Copyright by 布谷鸟
     */
    package gui;import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.MouseEvent;
    import org.eclipse.swt.events.MouseTrackAdapter;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Shell;/**
     * 
     * @Author cuckoo
     * @MSN [email protected]
     * @Time 16:30 
     * @Description 
     *  reset cursor and font style
     */
    public class QQLogin {
    public static void main(String args[]){
    new QQLogin().init();
    }
    private void init(){
    _shell = new Shell( _display );
    _shell.setSize(400, 300);
    _shell.setText(" QQ Login ");
    _applicationLabel = new Label( _shell,SWT.NONE);
    _applicationLabel.setText("申请帐户");
    _applicationLabel.setBounds(10, 10, 100, 20);
    _applicationLabel.addMouseTrackListener(new MouseTrackAdapter(){
    public void mouseEnter(MouseEvent e) {
    // TODO Auto-generated method stub
    _applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_RED));
    _applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_HAND));
    }
    public void mouseExit(MouseEvent e) {
    // TODO Auto-generated method stub
    _applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_BLACK));
    _applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_NO));
    }
    });
    _shell.open();
    while( !_shell.isDisposed()){
    if( !_display.readAndDispatch()){
    _display.sleep();
    }
    }
    _display.dispose();
    }
    private Display   _display =  Display.getDefault();
    private Shell     _shell = null ;
    private Label     _applicationLabel = null ;
    }
    -----------------------------------------------
    Quietly through ...
      

  3.   

    喜欢QQ,模仿lumaqq,提升自已技术!!
      

  4.   

    java中的DeskTop类很好的解决了这个问题。而且做出来的效果和你要的效果一模一样