This section outlines the steps to get started using the BitSlice components in building applications.
Integrating the Components into your IDE
Inserting a Visual Component into your Form, Compiling and
Running
The ‘Installation steps’ must be completed before integrating the
components into your IDE.
Integrating the components into the IDE involves the following main steps:
1.
Include the
directory <download dir>\BitSlice into the IDE’s class path.
2.
Include
BitSlice.jar into the IDE’s class path. This .jar file contains the component
suite.
3.
Include hsqldb.jar
into the IDE’s class path. This contains the HSQLDB database server, driver and
other related software. The BitSlice component suite comes with sample data
packaged in hsqldb tables. Once you go through this section, you can switch to
your own database, refer Creating and Using your own
database for this.
The following gives details of how the above steps can be done in
Eclipse IDE. The details for other IDEs would be similar.
1.
Create a
directory, say BitSliceTest which will be used as the workspace in eclipse
2.
Run Eclipse and
specify ‘BitSliceTest’ as the workspace during startup
3.
The package
explorer view is normally open by default. Create a new project, say
‘BitSliceTest’. To do this, right-click on the package explorer view, choose
‘New’, ‘Java Project’. This will bring up a window, enter your project name,
say ‘BitSliceTest’ and click on ‘Finish’.
4.
In the package
explorer view select your project. Click on ‘Window’, ‘Preferences’, ‘Java’,
‘Classpath variables’.
5.
Select ‘New’,
‘Folder’.
6.
Browse and
select the <download dir>\BitSlice folder. Enter a variable name, say
BitSliceFolder and click ‘OK’.
7.
In the package
explorer view, select your project. Click on ‘Window’, ‘Preferences’, ‘Java’,
‘Classpath variables’.
8.
Select ‘New’,
‘File’.
9.
Browse and
select the file <download dir>\<BitSlice>\BitSlice.jar. Enter a
variable name, say BitSliceJarFile and click ‘OK’.
10.
In the package
explorer view, select your project. Click on ‘Window’, ‘Preferences’, ‘Java’,
‘Classpath variables’.
11.
Select ‘New’,
‘File’.
12.
Browse and
select the file <download dir>\<BitSlice>\hsqldb.jar. Enter a
variable name, say HsqldbJarFile and click ‘OK’.
13.
In the package
explorer view right-click on your project and click on ‘Import’.
14.
Select ‘Archive
File’ and click ‘Next’.
15.
Browse and
select the file <download dir>\<BitSlice>\BitSlice.jar
16.
Click ‘Finish’
17.
Open out the
com\compositesoft\bitslice node to see the component subsystems and individual
components
18.
In the package
explorer view right-click on your project and click on ‘Properties’. Select
‘Java Build Path’, click on the ‘Libraries’ tab.
19.
Click on ‘Add
Variable’. Select the variable ‘BitSliceJarFile’ and click ‘Ok’. Click on ‘ok’
again to complete the operation.
To start using the components, do the following:
1.
Startup the
sample database by clicking on the BitSliceDbStartup icon created on your
desktop or by running the batch file BitSliceDbStartup.bat present in
<download dir>\BitSlice directory
2.
In case you
have a GUI editor/builder tool, such as Windows Builder installed, you can
install the visual components in the tool’s component palette and use them on
your forms using drag-drop operations
3.
Integrating the
components into the GUI editor involves the following steps:
·
Include the
directory <download dir>\BitSlice into the GUI editor’s class path.
·
Include
BitSlice.jar into the GUI editor’s class path.
·
Include
hsqldb.jar into the GUI editor’s class path.
·
Follow the
steps given in the GUI editor’s user manual for installing components into the palette
and inclusion and usage in forms/windows.
4.
The rest of
this section outlines how java code can be written to make use of the
components, assuming that no GUI editor is installed.
Refer the User Manual and API documentation for detailed usage instructions
of any component.
These steps outline how java code can be written to insert a visual component into the form, assuming that no GUI editor is installed. The steps given below pertain to Eclipse IDE. Other IDEs would have a similar set of steps.
We describe the code to instantiate a ‘CurrencyModify’
component for the currency ‘USD’ and insert it into a Java JFrame. The
component is capable of allowing user modifications to currency consistent with
business rules. The code for the example described below is present in
<download dir>\BitSlice\Docs\SamplePrograms\CurencyModifyTest.java
1.
Startup the
sample database by clicking on the BitSliceDbStartup icon created on your
desktop.
2.
Start the IDE.
The package explorer view is normally open by default.
3.
Select
BitSliceTest, Rightclick, select ‘New’, ‘class’
4.
Enter a name
for the class, say, CurrencyModifyTest
5.
In Superclass,
enter javax.swing.JFrame
6.
Tick the method
stubs to be created: Public static void main and Constructors from superclass
7.
Deselect the
stub Inherited methods from super class
8.
Click ‘Finish’
9.
The editor
creates a template of the program. Insert the following code:
1.
Additional
import statements, to import required java and BitSlice libraries
import
java.sql.*;
import
java.io.*;
import
com.compositesoft.bitslice.Currency.*;
import
com.compositesoft.bitslice.StaticDataManager.*;
2.
Class
level variable declarations, for the Currency Modify component and for the primary
key value of ‘USD’ which is passed as parameter to constructor while
instantiating the component.
CurrencyModify
cm;
String[]
pmkey = {"USD"};
3.
The
following code in the null constructor of the program, i.e, in
CurrencyModifyTest(). This code does the following:
1.
Instantiates
the CurrencyModify component for the currency
value ‘USD’
2.
Adds it
to the JFrame
3.
Sets the
title and size of the JFrame
4.
Traps
any exception and on error, shows a message in a window using the ComponentErrorMessage component
try {
cm = new
CurrencyModify(pmkey);
getContentPane().add(cm);
this.setTitle("Currency
Modify - BiSlice sample");
this.setSize(350, 350);
} catch (ClassNotFoundException e) {
new
ComponentErrorMessage(e.getMessage());
}catch (SQLException e) {
new
ComponentErrorMessage(e.getMessage());
}catch (IOException e) {
new
ComponentErrorMessage(e.getMessage());
}catch (ValidationException e) {
new
ComponentErrorMessage(e.getMessage());
}
4.
The following
code in ‘main’ to create an instance of the JFrame (CurrencyModifTest) and
show.
new
CurrencyModifyTest().setVisible(true);
10.
Compile and run
the program. You will get the form shown below.

Using the components with a GUI editor (Eclipse)
Most of
the programming described above is not required if you have a GUI
editor/builder installed and integrated into your Eclipse installation. With a
GUI editor, you may insert components into your form using simple drag-drop
operations and the required code will be automatically generated. Integrating the components into the GUI
editor involves the following steps:
·
Include the
directory <download dir>\BitSlice into the GUI editor’s class path.
·
Include
BitSlice.jar into the GUI editor’s class path.
·
Include
hsqldb.jar into the GUI editor’s class path.
·
Follow the
steps given in the GUI editor’s user manual for installing components into the
palette and inclusion and usage in forms/windows.
Refer the example described in Getting Started with Sun Studio 5
Update 1 CE. The steps for eclipse along with a GUI builder would be
similar to that described in this section.
Click here
to submit a bug or feature.
Please send us your comments and
suggestions. Visit us at compositesoft.com.
Copyright © 2000-2005
Composite Software Systems. All rights reserved.