Microsoft KB Archive/821320

= 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: &quot;No Overload for Method 'TextBox'&quot; =

Article ID: 821320

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual C# 2005 Express Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual J++ 1.0 Standard Edition

-



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.



Steps to Reproduce the Behavior
 Start Visual J++ 6.0. On the File menu, click New Project. Expand Visual J++ Projects, and then click Applications. In the right pane, double-click Windows Application. Name the project MyVJTestApplication, and then click Open. In Project Explorer, right-click Form1.java, and then click Rename.</li> Type TextFieldEx.java as the new name for Form1.java.</li>  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); } } </li> On the File menu, click Save All.</li> Quit Visual J++.</li> Start Microsoft Visual Studio .NET 2003 or Visual Studio 2005.</li> On the File menu, point to Open, and then click Convert.</li> In the Convert dialog box, click Java Language Conversion Assistant under Available Converters, and then click OK.</li> Follow the instructions in the JLCA Wizard to convert the Visual J++ project that you created in steps 2 through 6.</li> On the Build menu, click Build Solution.</li></ol>

<div class="references_section">