Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Re: RE: AspectJ with Applet

Hi, 
 
I am interested in your code too. I changed your code as Eric instructed. then run it using Run As Java Applet in Eclipse, it works fine. the attached is the source.
 
hope it is helpful to you.
 
thanks
 
guofeng

 
________________________________

From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Joanne (sent by Nabble.com)
Sent: Tue 9/27/2005 8:34 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Re: RE: AspectJ with Applet


Hi Eric, 
   Thanks a lot for your reply.  Sorry I was out of town for a week and couldn't reply promptly.  I tried what you suggested, using "execution" instead of "call", still nothing happened.  I'm really desperate now.... 
Do you have any simple example that actually made aspectj work with applet?  Thanks a lot! 

Joanne 

________________________________

Sent from the AspectJ - users <http://www.nabble.com/AspectJ-with-Applet-t316734.html#a966640>  forum at Nabble.com. 
/**
 * 
 */
package com.myapplet;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.*;

public class HelloWorldApplet extends Applet 
     implements MouseListener, MouseMotionListener 
{ 
    int width, height; 
    int mx, my;   
    boolean isButtonPressed = false; 

    public void init() { 
        width = getSize().width; 
        height = getSize().height; 
        setBackground( Color.black ); 

        mx = width/2; 
        my = height/2; 
        
        addMouseListener( this ); 
        addMouseMotionListener( this ); 
    } 
    
   public void paint( Graphics g ) { 
      if ( isButtonPressed ) { 
         g.setColor( Color.black ); 
      } 
      else { 
         g.setColor( Color.gray ); 
      } 
      g.fillRect( mx-20, my-20, 40, 40 ); 
   } 

    public void mouseClicked( MouseEvent e ) 
    { 
        isButtonPressed = !isButtonPressed; 
        repaint(); 
        e.consume(); 
    } 
    // ... no other Mouse actions are defined 

	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
} 
/**
 * 
 */
package com.myapplet;

import java.awt.event.*;

public aspect MyAppletAspect {
    pointcut callMouse(MouseEvent e) : args( e ) && execution(* *..HelloWorldApplet.mouse*(MouseEvent)); 
    
    before( MouseEvent e ) : callMouse(e) 
    { 
        System.out.println("mouse action" + " event: " + e ); 
    } 

}

Back to the top