BUG: Compilation errors occur in JLCA converted Visual J++ projects that implement Mouse Event methods (819602)



The information in this article applies to:

  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual J++ 6.0

SYMPTOMS

You have a Visual J++ Microsoft Windows application project that has a class that implements the following mouse event methods:
  • MouseMotionListener
  • MouseListener
When you convert your Visual J++ project to a Visual C# .NET project by using the Java Language Conversion Assistant (JLCA) tool, you receive the following compilation error message:
'System.EventArgs' does not contain a definition for 'X'
'System.EventArgs' does not contain a definition for 'Y'

CAUSE

When JLCA converts your Visual J++ project, it converts all the MouseEvent class objects to System.EventArgs class objects. The problem that is described in the "Symptoms" section occurs because the System.EventArgs class does not have properties named X and Y. Therefore, you receive compilation errors.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual J++ 6.0.
  2. On the File menu, click New Project.
  3. Expand Visual J++ Projects, click Applications, and then click Windows Application in the right pane.
  4. Name the project MyVJTestApplication, and then click Open.
  5. Replace the existing code with the following sample code for Form1.java:
    import java.awt.*;
    import java.awt.event.*;
    
    public class Form1 extends Frame
       implements MouseListener, MouseMotionListener
    {  
       public Form1()
       { 
          addWindowListener(new WindowAdapter() { public void
             windowClosing(WindowEvent e) { System.exit(0); } } );
          setSize(300, 200);
          setTitle(getClass().getName());
          addMouseListener(this);
       }
       
       // Implementing the mouse events of MouseListener and MouseMotionListener
       // If you do not implement these methods you receive compilation errors in VJ++ 
       
       public void mouseEntered(MouseEvent evt)
       {
    	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Entered", 1, 50);  
       }
       
       public void mousePressed(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Pressed", 1, 50);
       }
       public void mouseReleased(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Released", 1, 50);
       }
       public void mouseExited(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Exited", 1, 50);
       }
       public void mouseClicked(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Clicked", 1, 50);
       }
       
       public void mouseMoved(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Clicked", 1, 50);
       }
       
       public void mouseDragged(MouseEvent evt)
       {
       	 int xCoordinate = evt.getX();
         int yCoordinate = evt.getY();
    	 Graphics graphics = getGraphics();
         graphics.drawString("Clicked", 1, 50);
       }
       public static void main(String args[])
       {  Form1 myForm = new Form1();
          myForm.show();
       }
    }
    
    
  6. On the File menu, click Save All.
  7. Quit Visual J++.
  8. Start Microsoft Visual Studio .NET 2003.
  9. On the File menu, point to Open, and then click Convert.
  10. In Available Converters, click Java Language Conversion Assistant, and then click OK.
  11. Follow the instructions in the JLCA Wizard to convert the Visual J++ project that you created in steps 2 through 6.
  12. On the Build menu, click Build Solution.

REFERENCES

For more information about Java Language Conversion Assistant (JLCA), visit the following Microsoft Web site:

Modification Type:MinorLast Reviewed:1/12/2006
Keywords:kbWindowsForms kberrmsg kbcode kbEvent kbconvert kbJava kbbug KB819602 kbAudDeveloper