VJHandShaker: A Tool For Making Easy Java (Core) Interface Design From Visual Basic 6.0

Posted by in C# category on for Beginner level | Points: 250 | Views : 4101 red flag

VJHandShaker is an attempt to make an easy Java (Core) interface from VB. The software does not provide a full solution to the design development as of now but it presents an easy way to achieve the same.
The software is developed using C#.net 2010.

 Download source code for VJHandShaker: A Tool For Making Easy Java (Core) Interface Design From Visual Basic 6.0


Java since it's very inception, has been a good choice for the developers for developing applications. Because of its robustness, platform independentness and fully Object Oriented feature, it adds flavour to the developers. And so is Visual Basic (VB) which is also Object Oriented.

But the most catching feature in VB which Java (Core) is still lacking is it's easiness in making design interface. And a design constitutes an important part in the software development. Without a good look and feel, a software, though may have high functionality, can hardly strive for a long time in the market. So a meticulous design always gives an edge.

Making a complex design in Java as opposed to VB consumes a lot of time. So if the design can be done with accuracy added with rapidness, the development time can be greatly enhanced.

VJHandShaker sets a good focus on the above problem and gives an interesting solution.


VJHandShaker undergoes a number of steps for producing an optimal solution. A schematic diagram (Figure 1) depicted below presents an abstract view about it's working.

A bird's view of the above diagram is presented here.

The rudimentary Form (.frm file) is accepted as the input to the VJHandShaker which is then send to the next phase coined as Data Filtering. The raw data are processed in this phase, relevant properties pertaining to the individual controls (e.g. Textbox, Button etc.) are cropped and are then made ready for the Data Transformation phase's input. Here the informations related to the controls co-ordinate positions that were gathered in the previous steps are tuned inorder to make it appropriate for the java layout. The software has now enough information to give the resultant output i.e. a .java file.

The rest of the article is organized as follows:

  1. Section A describes a detailed view of the various stages of VJHandShaker.
  2. Section B illustrates the working process with detailed examples. It also shows the time taken for the conversation to take.
  3. Section C shows the controls that VJHandShaker has handshake with VB6.0 and J2SDK 1.4 so far.

Section A: Stages Of VJHandShaker1.0

Stage 1: Input Data (.frm file)

Visual Basic’s Form files (.frm) are pure ASCII files which can be viewed by any text editor. A Form file mainly manifests with the control details and the code. The typical structure of the form file is given below:

  1. The version number of the file format.
  2. A block of text containing the form description.
  3. A set of form attributes.
  4. Basic code for the form.

The FRM file introduces itself with version number of the file e.g. VERSION 6.00

The form description contains the form’s properties. The control informations are embedded within the form. Nested controls have their properties nested within the text of the container. In other words, all the controls informations and their properties are embedded within the parent control i.e. Form. The figure below presents the structure of the form description:

A quick walk-through of a typical Form (.frm) file will make the picture clear. Figure 3 shows a form design.

The code generated by the VB editor for the above form is presented below

Begin VB.Form frmMain 
   ClientHeight    =   2010
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4935
   LinkTopic       =   "Form1"
   ScaleHeight     =   2010
   ScaleWidth      =   4935
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton btnSubmit 
      Caption         =   "Submit"
      Height          =   495
      Left            =   1800
      TabIndex        =   2
      Top             =   1200
      Width           =   1455
   Begin VB.TextBox txtName 
      Height          =   495
      Left            =   1440
      TabIndex        =   1
      Top             =   360
      Width           =   3255
   Begin VB.Label lblName 
      Caption         =   "Name"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   975
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

As it can be seen from the above generated code that all the control informations maintain a particular pattern. They enclose themselves within the Begin and End statement. As said above that the Form occupies the top of the hierarchy among the controls- so all controls embed themselves within the Form's Begin and End statement.

Stage 2: Data Filtering

Data filtering is the process where the relevant informations are cropped from the raw VB Form (.frm) file. The cropping occurs as per a particular pattern. This stage is the heart of VJHandShaker. Data Filtering proceeds as per the following algorithm.

Algorithm for Data Filtering:

Step 1: Read the file content till the End-Of-file has reached.
Step 2: Identify the root element where the root element begins with Begin VB.Form 
Step 3: Pick out the Form Name and store in memory
Step 4: Pick out other Form informations and store in memory
Step 5: If the Form has no child, go to step 8
Step 6: If the Form has sub-elements, identify them with their respective structures. A typical sub-element structure is 
		Begin VB.Control <Control Name>
				Property Name1 = Property Value
				Property Name2 = Property Value
				. . . . . . . . . . . . . . . . . . . . . . . . . . . .
				 . . . . . . . . . . . . . . . . . . . . . . . . . . . .
				Property Name (n) = Property Value
Loop through the "Begin" statement of the sub-elements till the "End" statements has encounter and pick out the relevant informations and store in memory. Continue this process until the root element's (i.e. FORM) "End" statement has encountered. Then go to step 8.
Step 7: If the control has nested controls embedded within them, repeat step 6 until all the sub-elements and the root element's (i.e. FORM) "End" statement are processed. Then go to step 8.
Step 8: Send the informations to the Data Transformation stage

Stage 3: Data Transformation

VB and Java layout are different. It means the coordinate position of a control in VB doesn't hold the same in Java. Hence a transformation is needed. It is the process by which the control in both the applications will have the same appearance as far as User Interface is concern. This phase takes the input from Stage 2 and generates the output as a .java file.

The Data Transformation stage was built on a trial and error basis. The coordinate positions of the controls are captured in stage 2 by applying the above algorithm and there are divided by 14 for an almost precise look and feel of the controls.

Stage 4: Output Data (.java file)

This is the last step of the converter. It produces a .java file for each corresponding .frm file. Since Sun Micro System's convention of generating a .java file is that the file name (i.e. the .java file) and the class name should be same, VJHandShaker1.0 takes care of that too.

Section B: Working Process Of VJHandShaker1.0-Detailed Example

In this section a detailed view of the working of the VJHandShaker is presented.The interface of VJHandshaker is presented below.

The "Locate Project Folder" asks the user to choose the folder where .frm files are located. Once the user does that, the software will list the VB Form files(.frm(s)) in the "List Of VB Form Files" List Box as shown below

The List Box control will list the Filenames, their sizes in bytes, Creation Time and Last Access Time.For converting the VB Forms (.frm) to Java (.java) compatible, the user must click on the "Folder to Save Java Files" button which on the other hand will open Folder Browser Dialog Box. The user can either create a new folder for saving the .java files or can choose an existing folder for the same. The below figure will illustrate this.

Clicking on the "OK" button of the Folder Browser Dialog Box will initiate the process of conversion. The converted files will be list in the "List Of Java Files" List Box. The total conversion time will be highlighted in the top right corner beside the "Processing Time" label in milliseconds. A progress bar will indicate the actual conversion progress. This is shown below

For a detailed walk through of VJHandShaker, first of all we will design a Form in VB6.0.

Working Of Design1

The above design is only a blank VB Form devoid of any control. The code generated by the VB editor for the above design is as follows

Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

The corresponding .java file generated by VJHandShaker is presented below

The code generated by the software is as under

import javax.swing.*;
import java.awt.*;
public class Form1 extends JFrame
 	 public Form1()
 		 Container con = getContentPane();
	public static void main(String args[])
	              Form1 app = new Form1();

Working Of Design2

This is a more sophisticated design. It depicts a Registration Form.The corresponding .java design produced by VBHandShaker1.0 is as under

The corresponding code generated is given below

import javax.swing.*;
import java.awt.*;
public class frmRegistration extends JFrame
 	 public frmRegistration()
 		 Container con = getContentPane();
 		 JButton Cancel = new JButton("Cancel");
 		 JButton btnSubmit = new JButton("Submit");
 		 JComboBox cmbNation = new JComboBox();
 		 //  OR 
 		 //Choice cmbNation = new Choice();
 		 // con.add(cmbNation);
 		 JTextField txtEmail = new JTextField();
 		 JTextField txtPhone = new JTextField();
 		 JTextField txtFatherName = new JTextField();
 		 JTextField txtAge = new JTextField();
 		 JRadioButton opMale = new JRadioButton("Male");
 		 JRadioButton opFemale = new JRadioButton("Female");
 		 JTextArea txtAddress = new JTextArea();
 		 JScrollPane txtAddressSP = new JScrollPane( txtAddress,          
 		 JCheckBox chkGame = new JCheckBox("Game");
 		 JCheckBox chkReading = new JCheckBox("Reading");
 		 JCheckBox chkFishing = new JCheckBox("Fishing");
 		 JCheckBox chkQuize = new JCheckBox("Quize");
 		 JCheckBox chkStamp = new JCheckBox("Stamp");
 		 JCheckBox chkCoin = new JCheckBox("Coin");
 		 JComboBox cmbDate = new JComboBox();
 		 //  OR 
 		 //Choice cmbDate = new Choice();
 		 // con.add(cmbDate);
 		 JComboBox cmbMonth = new JComboBox();
 		 //  OR 
 		 //Choice cmbMonth = new Choice();
 		 // con.add(cmbMonth);
 		 JComboBox cmbYear = new JComboBox();
 		 //  OR 
 		 //Choice cmbYear = new Choice();
 		 // con.add(cmbYear);
 		 JTextField txtName = new JTextField();
 		 ImageIcon imgPhoto = new ImageIcon("blank.gif");
 		 JLabel lblimgPhoto = new JLabel(imgPhoto,JLabel.CENTER);
 		 JLabel lblNation = new JLabel("Nation :");
 		 JLabel lblEmail = new JLabel("Emal :");
 		 JLabel lblPrimaryPhone = new JLabel("Phone :");
 		 JLabel lblFatherName = new JLabel("Father Name :");
 		 JLabel lblAge = new JLabel("Age :");
 		 JLabel lblSex = new JLabel("Sex :");
 		 JLabel lblAdress = new JLabel("Address :");
 		 JLabel lblHobbies = new JLabel("Hobbies :");
 		 JLabel lblDob = new JLabel("DOB :");
 		 JLabel lblName = new JLabel("Name :");
 		 JLabel lblRegForm = new JLabel("Registration Form");
	public static void main(String args[])
 		 frmRegistration app = new frmRegistration();

Working Of Design3

The last but not the least design is about some more controls which the software has learnt about. This is presented in the below screen shot.

VJHandShaker gives the following output

Section C: Handshaking of Controls between VB Forms and JAVA

The following table presents a roster of controls that VJHandShaker1.0 has mapped so far


  1. http://msdn2.microsoft.com/en-us/library/aa241723.aspx
  2. Java 2:The Complete Reference, Third Edition (Patrick Naughton & Herbert Schildt)
  3. C#.Net fundas (Yashavant Kanetkar)
  4. Mastering Visual Basic 6 (Evangelos Petroutsos)


VJHandShaker1.0 is an attempt to make a quick java design interface from VB. However, it can also be used to convert the design interface of any legacy application built in VB to Java too. Also it reduces the design time of the java application.I hope, that, my readers will like the concept and will extend the software. Zipped files is attached herewith.Thanks for reading.

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Niladri Biswas
Member Level: Platinum
Member Status: Member
Member Since: 10/25/2010 11:04:24 AM
Country: India
Best Regards, Niladri Biswas
Technical Lead at HCL Technologies

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)