Package com.yc.utils;
Import java.sql.SQLException;
public class Shellutil { Private Boolean flag=false; private int xx; The x-axis of the mouse position when you click the interface private int yy; The y-axis of the mouse position when you click the interface
Main Panel off Button listener event 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) {//background map when mouse moves Label.setimage (Swtresourcemanager.getimage (Login.class, "/pic/btn_close_highlight.png")); } });
Mouse Listener Events
Label.addmouselistener (New Mouseadapter () { @Override public void MouseDown (MouseEvent e) {//Background image when Mouse is pressed Label.setimage (Swtresourcemanager.getimage (Login.class, "/pic/btn_close_down.png")); }
@Override public void MouseUp (MouseEvent e) {//Mouse release Ifmessagedialog.openconfirm (Parent.getshell (), "Warm Prompt", "Are you sure you want to exit?");){ Shell.close (); } } });}
Close button Eventpublic 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 (); } });}
Minimize button Eventspublic 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 () {Minimized interface @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); } });}
Maximize button Eventspublic 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 () { Maximizing the interface @Override public void MouseDown (MouseEvent e) { Label.setimage (Swtresourcemanager.getimage (Login.class, "/pic/btn_max_down.png")); Shell.setmaximized (TRUE); } });}
Mobile interface Methodpublic 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; } }); }}
Some operations after the shell is set to none