PRB: You Receive Compilation Errors in a Visual J++ Windows Application That JLCA Converts by Using the getClick Method (819604)



The information in this article applies to:

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

SYMPTOMS

After you convert a Visual J++ project to a Visual C# .NET project by using Java Language Conversion Assistant (JLCA), you receive the following error message during compilation of the generated Visual C# .NET project:
The keyword new is required on 'ClassName.Click' because it hides inherited member 'System.Windows.Forms.Control.Click'
This error occurs when the Visual J++ project contains a java.awt.Frame derived class and a getClick() method.

CAUSE

While converting the Visual J++ project to a Visual C# .NET project, JLCA converts the getClick() method to a Click property. Because the generated Visual C# .NET class is derived from the System.Windows.Forms.Form class (which has a Click property), you receive the error message.

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. On the New tab, expand Visual J++ Projects, and then expand Applications.
  4. In the right pane, click Windows Application.
  5. Name the project by typing MyVJTestWindowsApplication, type the Location as C:\, and then click Open.
  6. In Project Explorer, right-click MyVJTestWindowsApplication, point to Add, and then click Add Class.
  7. Name the class file by typing CloseableFrame.java, and then click Open.
  8. Replace the existing code with the following sample code:
    package CloseableFramePackage;
    import java.awt.*;
    import java.awt.event.*;
    
    public class CloseableFrame extends Frame 
    {  public CloseableFrame()
       {  
    	addWindowListener(new WindowAdapter() { public void
             windowClosing(WindowEvent e) { System.exit(0); } } );
          setSize(300, 200);
          setTitle(getClass().getName());
       }
    }
    
  9. In Project Explorer, right-click Form1.java, and then click Rename.
  10. Type EventQueueTest.java as the new name for Form1.java.
  11. In Project Explorer, right-click EventQueueTest.java, and then click View Code.
  12. Replace the existing code with the following sample code:
    import java.awt.*;
    import java.awt.event.*;
    import CloseableFramePackage.*;
    
    public class EventQueueTest extends CloseableFrame
    {  public void run()
       {  displayPrompt("Please click on a point");
          Point myPoint = getClick();				
          displayPrompt("Please click on another point");
          Point myAnotherPoint = getClick();				
          Graphics myGraphObj = getGraphics();
          myGraphObj.translate(getInsets().left, getInsets().top);
          myGraphObj.drawLine(myPoint.x, myPoint.y, myAnotherPoint.x, myAnotherPoint.y);
          displayPrompt("Done!");
       }
    
       public void displayPrompt(String s)
       {  Graphics myGraphObj = getGraphics();
          myGraphObj.translate(getInsets().left, getInsets().top);
          myGraphObj.clearRect(0, 0, getSize().width, 50);
          myGraphObj.drawString(s, 0, 30);
       }
    
       public Point getClick()		
       {  EventQueue eventQ 
             = Toolkit.getDefaultToolkit()
                .getSystemEventQueue();
          while (true)
          {  try
             {  AWTEvent myEvent = eventQ.getNextEvent();
                if (myEvent.getID() == MouseEvent.MOUSE_CLICKED)
                {  MouseEvent mouseEvent = (MouseEvent)myEvent;
                   Point myPoint = mouseEvent.getPoint();
                   Graphics myGraphObj = getGraphics();
                   myGraphObj.translate(getInsets().left, getInsets().top);
                   myGraphObj.drawOval(myPoint.x - 2, myPoint.y - 2, 4, 4);
                   return myPoint;         
                }
             }
             catch(InterruptedException e)
             {}
          }
       }
    
       public static void main(String[] args)
       {  EventQueueTest myEventQueueTest = new EventQueueTest();
          myEventQueueTest.show();
          myEventQueueTest.run();
       }
    }
  13. On the File menu, click Save All, and then quit Visual J++.
  14. Start Visual Studio .NET 2003.
  15. On the File menu, point to Open, and then click Convert.
  16. Click to select the Java Language Conversion Assistant check box under the Available Converters section.
  17. Click to select the Create new solution check box, and then click OK.
  18. Follow the instructions in Java Language Conversion Assistant wizard to convert the Visual J++ project.
  19. On the Build menu, click Build Solution.

    You receive the compilation error that is mentioned in the "Symptoms" section of this article.

REFERENCES

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

Modification Type:MinorLast Reviewed:8/15/2005
Keywords:kberrmsg kbCodeGen kbWindowsForms kbJava kbconvert kbbug KB819604 kbAudDeveloper