Error message when you compile a project that you converted from Visual J++ to Visual C# .NET or Visual C# 2005 by using the Java language conversion assistant: "No Overload for Method 'TextBox'" (821320)



The information in this article applies to:

  • Microsoft Visual C# 2005, Express Edition
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual J++ 1.0

SYMPTOMS

When you convert a Visual J++ project to a Visual C# .NET or a Visual C# 2005 project by using Java Language Conversion Assistant (JLCA), and then you compile the generated Visual C# .NET project or the generated Visual C# 2005 project, you may receive one of the following error messages:
No overload for method 'TextBox' takes '1' arguments
-or-
No overload for method 'TextBox' takes '2' arguments
This error occurs only when the Visual J++ project contains a java.awt.TextField derived class and you have used any one of the following java.awt.TextField constructors in the derived class constructor:
  • TextField(String text)
  • TextField(int columns)
  • TextField(String text, int columns)

CAUSE

In Visual C# .NET or Visual C# 2005, the System.Windows.Forms.TextBox class supports only the TextBox constructor. This constructor has no parameters. However, in Visual J++, the java.awt.TextField class supports the following four constructors:
  • TextField
  • TextField(int columns)
  • TextField(String text)
  • TextField(String text, int columns)
When you convert your project from Visual J++ to Visual C# .NET or Visual C# 2005, JLCA converts any TextField constructor to a TextBox constructor. However, because the TextBox constructor does not use parameters, you receive the compilation error message.

RESOLUTION

To resolve this problem, remove the parameters from the constructor of the base class base in the Visual C# .NET or Visual C# 2005 code that JLCA generates, as in the following sample code:
public TextFieldEx():base()
{
}

public TextFieldEx(System.String text):base()
{
	this.Text = text;
}

public TextFieldEx(int noOfColumns):base()
{
}
	
public TextFieldEx(System.String text, int noOfColumns):base()
{
	this.Text = text;
}

STATUS

This behavior is by design.

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, and then click Applications.
  4. In the right pane, double-click Windows Application.
  5. Name the project MyVJTestApplication, and then click Open.
  6. In Project Explorer, right-click Form1.java, and then click Rename.
  7. Type TextFieldEx.java as the new name for Form1.java.
  8. Replace the existing code with the following sample code for TextFieldEx.java:
    import java.awt.*;
    
    public class TextFieldEx extends TextField 
    {
    	public TextFieldEx()
    	{
    		super();		
    	}
    
    	public TextFieldEx(String text)
    	{
    		super(text);		
    	}
    	public TextFieldEx(int noOfColumns)
    	{
    		super(noOfColumns);		
    	}
    	
    	public TextFieldEx(String text, int noOfColumns)
    	{
    		super(text, noOfColumns);		
    	}
    	
    }
  9. On the File menu, click Save All.
  10. Quit Visual J++.
  11. Start Microsoft Visual Studio .NET 2003 or Visual Studio 2005.
  12. On the File menu, point to Open, and then click Convert.
  13. In the Convert dialog box, click Java Language Conversion Assistant under Available Converters, and then click OK.
  14. Follow the instructions in the JLCA Wizard to convert the Visual J++ project that you created in steps 2 through 6.
  15. On the Build menu, click Build Solution.

REFERENCES

For more information about JLCA, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:1/18/2006
Keywords:kbwizard kbWindowsForms kbCodeGen kbconvert kbCompiler kbJava kbprb KB821320 kbAudDeveloper