Pre-requisites:
Summary:
Here we show a small banking application to illustrate how to code in Java for UNICODE titles & input using Aksharamala. In this sample we create new accounts with minimum data to be accepted and display the same using JTable control. The main focus of this sample is to accept and display the data in Indian languages (in this case Hindi Transliteration Scheme).
Design
In this sample, we have designed a form to accept and display account details (Figure 1). We used Netbeans version 3.4 to design and develop the application.
Figure 1
Setting the properties of controls during design time
To set the text property of a control in Indian Language (say Hindi Language), enable Hindi Transliteration Scheme from the Aksharamala tray icon (Figure 2) and go to the properties window in Netbeans IDE to set the properties of the selected control (Figure 3).
Figure 2
Figure 3
When the application runs, the text property thus set for a control will be displayed as entered during design time (in the source code it may be stored differently say in unicode format. For example the jLabel1 text property is stored as jLabel1.setText("\u0916\u093e\u0924\u093e") in the source code, but displayed as entered as shown in Figure 1 and Figure 3).
For some controls say combo box we have to work around to get the appropriate results. Do the following to set the values of list in the combo box. This will ensure that during run time that the data is displayed as required.
- Set the text property of a jLabel field in Hindi as required.
- Go to the source code (initcomponents() method) and find the value set for this jLabel field. The value set should be in unicode format (say jLabel1.setText("\u0916\u093e\u0924\u093e")).
- Copy the unicode string of the jLabel into the item list property (from properties window) of combo box as shown in Figure 4.
- Repeat the above procedure for different values to be set into the combo box.
Figure 4
Database
In this sample, we store the data in file in UTF8 format, using "|" delimiter to separate the data fields.
Events/Actions
Application Startup
The form shown in Figure 5 is displayed when application is executed.
Figure 5
Save To List
Enable the appropriate Indian language (say Hindi language) from the Aksharamala tray icon. Enter the data and press "Save To List" button. This will add the data to the list control (jTable control) as shown in Figure 6.
Figure 6
Save List To File
Click the "Save List To File" button to save the data in the list control (jTable), thus entered in step "Save To List". This will save the data to a file in UTF8 format (bank.dat).
Read From File
Click the "Read From File" button to retrieve the data saved in step "Save List To File". This will retrieve the data from file (bank.dat) and populates the same to the list control (jTable).
Clear List Entries
Click the "Clear List Entries" button to clear the list entries.
Notes
- For simplicity, security, user and data access validations are omitted in this example. Users are advised to implement their own security, user and data access validations.
- For this example, we used Netbeans version 3.4. The source code may have some dependencies of Netbeans environment.
|