www.digitalmars.com         C & C++   DMDScript  

c++.announce - Migrate .Net Windows Forms to Java using CodePorting App

CodePorting Application is always making efforts to improve its 
features list to make it the best online C# to Java conversion 
service for developers. One of such feature is converting C# 
windows forms to Java.

This is a great feature that will reduce the cost and effort to 
convert C# Windows form application to java.  CodePorting 
Engineers are currently upgrading C#2Java engine to take this 
idea further and make this feature more powerful for future 
desktop application. To start this feature CodePorting has 
successfully ported simple desktop application to java.

CodePorting is using Swing components instead of AWT to convert 
.Net forms to Java because it is easily convertible and provide 
wide range of features such as icons, pop-ups, tool-tips, and its 
plug-able look & feel makes it fit in any OS environment.  
C#2Java engine also converts form events to java. To accommodate 
this new feature, codeporting has enhanced the core, created some 
new Java library classes and updated the mappings files.

Below Example shows the conversion of C# Windows form to Java.

C# Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CsPorter.Tests.Convert.Forms
{
     public class Test2 : Form
     {
         public Test2()
         {
             initUI();
         }

         public void initUI ()
         {
             Panel panel = new Panel ();
             panel.Location = new System.Drawing.Point (-1, 0);
             //panel.SuspendLayout();
             panel.Size = new System.Drawing.Size (285, 261);

             TextBox text1 = new TextBox ();
             text1.Location = new System.Drawing.Point (25, 25);
             text1.Text = "Autoported using C#2Java";
             text1.Size = new System.Drawing.Size (150, 25);

             Label label1 = new Label ();
             label1.Location = new System.Drawing.Point (25, 50);
             label1.Text = "label1";

             Button button1;
             button1 = new Button ();
             button1.Location = new System.Drawing.Point (25, 75);
             button1.Name = "button name";
             button1.Text = "button 1";
             button1.Size = new System.Drawing.Size (75, 23);

             button1.Click += new System.EventHandler 
(button1_Click);

             panel.Controls.Add (label1);
             panel.Controls.Add (text1);
             panel.Controls.Add (button1);
             button1.Visible = true;
             Controls.Add (panel);

             Size = new System.Drawing.Size (300, 290);
         }

         private void button1_Click (object sender, EventArgs e)
         {
             MessageBox.Show ("Autoported using C#2Java");
         }

         public static void main(String[] args)
         {

         }
     }
}



Java Code:
package CsPorter.Tests.Convert.Forms;

// ********* THIS CODE IS AUTO PORTED FROM C# TO JAVA USING 
CODEPORTING.COM TECHNOLOGY *********

import com.codeporting.csharp2java.System.Windows.Forms.Form;
import com.codeporting.csharp2java.System.Windows.Forms.Panel;
import javax.swing.JTextField;
import javax.swing.JLabel;
import com.codeporting.csharp2java.System.Windows.Forms.Button;
import java.awt.event.ActionEvent;
import 
com.codeporting.csharp2java.System.Windows.Forms.MessageBox;

public class Test2 extends Form
{
     public Test2()
     {
         initUI();
     }

     public void initUI ()
     {
         Panel panel = new Panel ();
         panel.setLocation(new 
com.codeporting.csharp2java.System.Drawing.Point (-1, 0));
         //panel.SuspendLayout();
         panel.setSize(new 
com.codeporting.csharp2java.System.Drawing.Size (285, 261));

         JTextField text1 = new JTextField ();
         text1.setLocation(new 
com.codeporting.csharp2java.System.Drawing.Point (25, 25));
         text1.setText("Autoported using C#2Java");
         text1.setSize(new 
com.codeporting.csharp2java.System.Drawing.Size (150, 25));

         JLabel label1 = new JLabel ();
         label1.setLocation(new 
com.codeporting.csharp2java.System.Drawing.Point (25, 50));
         label1.setText("label1");

         Button button1;
         button1 = new Button ();
         button1.setLocation(new 
com.codeporting.csharp2java.System.Drawing.Point (25, 75));
         button1.setName("button name");
         button1.setText("button 1");
         button1.setSize(new 
com.codeporting.csharp2java.System.Drawing.Size (75, 23));

         button1.setClick(new 
com.codeporting.csharp2java.System.Windows.Forms.EventHandler 
(this,"button1_Click"));

         panel.getControls().add (label1);
         panel.getControls().add (text1);
         panel.getControls().add (button1);
         button1.setVisible(true);
         getControls().add (panel);

         setSize(new 
com.codeporting.csharp2java.System.Drawing.Size (300, 290));
     }
     public void button1_Click (Object sender, ActionEvent e)
     {
         MessageBox.show ("Autoported using C#2Java");
     }

     public static void main(String[] args)
     {

     }
}
Oct 02 2012