ABSTARCT
VJHandShaker1.0 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.
INTRODUCTION
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.
VJHandShaker1.0 sets a good focus on the above problem and gives an interesting solution.
PROCESS
VJHandShaker1.0 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 VJHandShaker1.0 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.
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:
- The version number of the file format.
- A block of text containing the form description.
- A set of form attributes.
- Basic code for the form.,/li>
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
VERSION 5.00
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
End
Begin VB.TextBox txtName
Height = 495
Left = 1440
TabIndex = 1
Top = 360
Width = 3255
End
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
EndProperty
Height = 375
Left = 240
TabIndex = 0
Top = 480
Width = 975
End
End
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 VJHandShaker1.0. 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 <FormName>
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 <c>
Property Name1 = Property Value
Property Name2 = Property Value
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
Property Name (n) = Property Value
End
</c>
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 VJHandShaker1.0 is presented.
The interface of VJHandshaker1.0 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 VJHandShaker1.0, 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
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
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 VJHandShaker1.0 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()
{
super("Form1");
Container con = getContentPane();
con.setLayout(null);
setSize(334,220);
setResizable(true);
setVisible(true);
}
public static void main(String args[])
{
Form1 app = new Form1();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
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()
{
super("RegistrationForm");
Container con = getContentPane();
con.setLayout(null);
JButton Cancel = new JButton("Cancel");
Cancel.setBounds(402,394,95,35);
con.add(Cancel);
JButton btnSubmit = new JButton("Submit");
btnSubmit.setBounds(300,394,95,35);
con.add(btnSubmit);
JComboBox cmbNation = new JComboBox();
cmbNation.setBounds(420,300,223,22);
con.add(cmbNation);
JTextField txtEmail = new JTextField();
txtEmail.setBounds(420,257,223,26);
con.add(txtEmail);
JTextField txtPhone = new JTextField();
txtPhone.setBounds(420,214,223,26);
con.add(txtPhone);
JTextField txtFatherName = new JTextField();
txtFatherName.setBounds(420,68,181,26);
con.add(txtFatherName);
JTextField txtAge = new JTextField();
txtAge.setBounds(77,120,69,26);
con.add(txtAge);
JRadioButton opMale = new JRadioButton("Male");
opMale.setBounds(420,111,52,26);
con.add(opMale);
JRadioButton opFemale = new JRadioButton("Female");
opFemale.setBounds(488,111,61,26);
con.add(opFemale);
JTextArea txtAddress = new JTextArea();
txtAddress.setEditable(true);
JScrollPane txtAddressSP = new JScrollPane( txtAddress,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
txtAddressSP.setLocation(77,171);
txtAddressSP.setSize(223,103);
con.add(txtAddressSP);
JCheckBox chkGame = new JCheckBox("Game");
chkGame.setBounds(77,291,52,18);
con.add(chkGame);
JCheckBox chkReading = new JCheckBox("Reading");
chkReading.setBounds(145,291,69,18);
con.add(chkReading);
JCheckBox chkFishing = new JCheckBox("Fishing");
chkFishing.setBounds(231,291,61,26);
con.add(chkFishing);
JCheckBox chkQuize = new JCheckBox("Quize");
chkQuize.setBounds(77,317,52,18);
con.add(chkQuize);
JCheckBox chkStamp = new JCheckBox("Stamp");
chkStamp.setBounds(145,317,61,26);
con.add(chkStamp);
JCheckBox chkCoin = new JCheckBox("Coin");
chkCoin.setBounds(231,317,61,26);
con.add(chkCoin);
JComboBox cmbDate = new JComboBox();
cmbDate.setBounds(420,171,61,22);
con.add(cmbDate);
JComboBox cmbMonth = new JComboBox();
cmbMonth.setBounds(488,171,86,22);
con.add(cmbMonth);
JComboBox cmbYear = new JComboBox();
cmbYear.setBounds(582,171,61,22);
con.add(cmbYear);
JTextField txtName = new JTextField();
txtName.setBounds(77,68,223,26);
con.add(txtName);
ImageIcon imgPhoto = new ImageIcon("blank.gif");
JLabel lblimgPhoto = new JLabel(imgPhoto,JLabel.CENTER);
lblimgPhoto.setBounds(617,17,128,130);
con.add(lblimgPhoto);
JLabel lblNation = new JLabel("Nation :");
lblNation.setBounds(334,300,61,18);
con.add(lblNation);
JLabel lblEmail = new JLabel("Emal :");
lblEmail.setBounds(334,257,52,18);
con.add(lblEmail);
JLabel lblPrimaryPhone = new JLabel("Phone :");
lblPrimaryPhone.setBounds(334,214,52,18);
con.add(lblPrimaryPhone);
JLabel lblFatherName = new JLabel("Father Name :");
lblFatherName.setBounds(325,68,78,18);
con.add(lblFatherName);
JLabel lblAge = new JLabel("Age :");
lblAge.setBounds(8,120,35,18);
con.add(lblAge);
JLabel lblSex = new JLabel("Sex :");
lblSex.setBounds(334,120,35,18);
con.add(lblSex);
JLabel lblAdress = new JLabel("Address :");
lblAdress.setBounds(8,171,52,26);
con.add(lblAdress);
JLabel lblHobbies = new JLabel("Hobbies :");
lblHobbies.setBounds(8,291,52,18);
con.add(lblHobbies);
JLabel lblDob = new JLabel("DOB :");
lblDob.setBounds(334,171,43,18);
con.add(lblDob);
JLabel lblName = new JLabel("Name :");
lblName.setBounds(8,68,43,26);
con.add(lblName);
JLabel lblRegForm = new JLabel("Registration Form");
lblRegForm.setBounds(300,17,103,18);
con.add(lblRegForm);
setSize(767,547);
setResizable(true);
setVisible(true);
}
public static void main(String args[])
{
frmRegistration app = new frmRegistration();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
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.
VJHandShaker1.0 gives the following output
VJHandShaker1.0 is meant for multiple files conversion i.e. a project conversion.
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
No. | VB Control Names | JAVA Control Names |
1 | VB.Form | JFrame() |
2 | VB.Lable | JLable() |
3 | VB.TextBox | JTextField()[Single Line TextBox] |
4 | VB.TextBox | JTextArea()[Multiline TextBox] |
5 | VB.Button | JButton() |
6 | VB.RadioButton | JRadioButton() |
7 | VB.CheckBox | JCheckBox() |
8 | VB.SSTab | JTabbedPane() |
9 | HScrollBar | JScrollBar(JScrollBar.HORIZONTAL) |
10 | VScrollBar | JScrollBar(JScrollBar.VERTICAL) |
11 | ListBox | List() |
12 | ComboBox | Choice() |
13 | VB.PictureBox | ImageIcon() |
14 | VB.Image | ImageIcon() |
15 | VB.Frame | JPanel() |
16 | ComctlLib.ProgressBar | JProgressBar() |
17 | ComctlLib.Slider | JSlider() |
Section D: Conclusion
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.
Section E: Future Enhancements
Though VJHandShaker1.0 has achieved its initial target but still it needs to be nourished properly in order to obtain its real power. The software forecasts only on converting the VB interface design to Java (Core) interface design. The target platform can be enumerated to C, C++ environments. Also if the demand goes from Oracle Forms, Dot Net, Html or other platforms that assist in designing, those applications design can be converted to Java’s design layout. The project is an ongoing one. It has got only a limited capacity of around seventeen controls to map from VB to Java. But the future demands more and hence VJHandShaker1.0 may come in future as MPJHandShaker (ManyToJavaHandShaker).
Section F: Bibliographies & References
http://msdn2.microsoft.com/en-us/library/aa241723.aspx
Java 2:The Complete Reference, Third Edition (Patrick Naughton & Herbert Schildt)
C#.Net fundas (Yashavant Kanetkar)
Mastering Visual Basic 6 (Evangelos Petroutsos)