FileDocCategorySizeDatePackage
MouseListenerExample.javaAPI DocExample1303Sun Oct 31 09:31:08 GMT 2004None

MouseListenerExample

public class MouseListenerExample extends Object

Fields Summary
final Display
d
final Shell
s
Constructors Summary
public MouseListenerExample()

        d = new Display();
        s = new Shell(d);
        
        s.setSize(250,200);
        s.setImage(new Image(d, "c:\\icons\\JavaCup.ico"));
        s.setText("A MouseListener Example");
        s.open();
        
        s.addMouseListener(new MouseListener() {
            public void mouseDown(MouseEvent e) {
                Label l = new Label(s, SWT.FLAT);
                l.setText("Mouse Button Down at:" + e.x + " " + e.y);
                l.setBounds(e.x,e.y, 150,15);
                
            }
            public void mouseUp(MouseEvent e) {
                Label l = new Label(s, SWT.FLAT);
                l.setText("Mouse Button up at:" + e.x + " " + e.y);
                l.setBounds(e.x,e.y, 150,15);
            }
            public void mouseDoubleClick(MouseEvent e) {
                                
            }
        });       
        
        while(!s.isDisposed()){
            if(!d.readAndDispatch())
                d.sleep();
        }
        d.dispose();
    
Methods Summary