shell设为NONE后的一些操作

 package com.yc.utils;

import java.sql.SQLException;

public class ShellUtil {
    private boolean flag=false;
    private int xx; //点击界面时鼠标所在的位置的x轴
    private int yy;  //点击界面时鼠标所在位置的y轴

    
//主面板关闭按钮监听事件
    public void OpbuttonClose(final Label label,final Shell shell,final String uaccount ){
        label.addMouseTrackListener(new MouseTrackAdapter() {
            @Override
            public void mouseExit(MouseEvent e) {
                label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_normal.png"));
            }
    });
 
    label.addMouseMoveListener(new MouseMoveListener() {
        public void mouseMove(MouseEvent arg0) { //鼠标移动时的背景图
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_highlight.png"));
        }
    });
     
     //鼠标监听事件
     
label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) { //鼠标按下时的背景图
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_down.png"));
        }

         
@Override
        public void mouseUp(MouseEvent e) { //鼠标松开时
            if(MessageDialog.openConfirm(parent.getShell(),"温馨提示","您确认要退出吗?"); ){
                shell.close();
            }
        }
    });
}
 
//关闭按钮事件
public void buttonClose(final Label label,final Shell shell){
    label.addMouseTrackListener(new MouseTrackAdapter() {
    @Override
        public void mouseExit(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_normal.png"));
        }
    });
 
    label.addMouseMoveListener(new MouseMoveListener() {
        public void mouseMove(MouseEvent arg0) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_highlight.png"));
        }
    });
 
    label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_close_down.png"));
        }
        @Override
        public void mouseUp(MouseEvent e) {
            shell.close();
        }
    });
}
 
//最小化按钮事件
public void buttonMin(final Label label,final Shell shell){
    label.addMouseTrackListener(new MouseTrackAdapter() {
       @Override
       public void mouseExit(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_mini_normal.png"));
        }
    });
 
    label.addMouseMoveListener(new MouseMoveListener() {
        public void mouseMove(MouseEvent arg0) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_mini_highlight.png"));
        }
    });
 
    label.addMouseListener(new MouseAdapter() {
        //最小化界面
        @Override
        public void mouseDown(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_mini_down.png"));
        }
 
        public void mouseUp(MouseEvent e) {
            shell.setMinimized(true);
        }
    });
}

 
//最大化按钮事件
public void buttonMax(final Label label,final Shell shell){
    label.addMouseTrackListener(new MouseTrackAdapter() {
        @Override
        public void mouseExit(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_max_normal.png"));
        }
        });
 
    label.addMouseMoveListener(new MouseMoveListener() {
        public void mouseMove(MouseEvent arg0) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_max_highlight.png"));
        }
    });
 
    label.addMouseListener(new MouseAdapter() {
        //最大化界面
        @Override
        public void mouseDown(MouseEvent e) {
            label.setImage(SWTResourceManager.getImage(Login.class, "/pic/btn_max_down.png"));
            shell.setMaximized(true);
        }
    });
}
 
//移动界面方法
public void shellMove(final Composite composite,final Shell shell){
    composite.addMouseMoveListener(new MouseMoveListener() {
        public void mouseMove(MouseEvent arg0) {
            if(flag){
                shell.setBounds(shell.getLocation().x+arg0.x-xx, shell.getLocation().y+arg0.y-yy ,shell.getBounds().width, shell.getBounds().height);
            }
        }
    });
 
    composite.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            flag = true;
            xx = e.x;
            yy = e.y;
        }
 
        @Override
        public void mouseUp(MouseEvent e) {
            flag=false;
        }
    });
    }
}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。