//Book.java
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.data.*;
import com.ms.wfc.data.ui.*;
public class Book extends Form
{
Recordset m_rs;
Connection m_con;
DataBinder m_dataBinder;
protected void finalize()
{
try
{
m_rs.close();
m_con.close();
}
catch (Exception e)
{
handleADOException( e );
}
}
public void dispose()
{
super.dispose();
components.dispose();
}
public Book()
{
// Required for Visual J++ Form Designer
support
initForm();
this.show();
this.update();
//TODO: Add any constructor code after
initForm call
try
{
openDataConnection();
initializeBindings();
}
catch (Exception e)
{
handleADOException( e );
}
}
public void btnClose_Click(Object sender,
Event evt)
{
Application.exit();
}
public void formClose(Event e)
{
Application.exit();
}
void openDataConnection()
{
m_con = new Connection();
m_rs = new Recordset();
m_con.setConnectionString ("PROVIDER=Microsoft.Jet.OLEDB.3.51;Data
Source=C:\\TestVJ\\Pic\\KJV.mdb");
m_con.setCursorLocation (AdoEnums.CursorLocation.CLIENT);
m_con.open();
m_rs.setActiveConnection(m_con);
m_rs.setSource("select Book,
BookTitle, Chapter, Verse, TextData from
BibleTable");
m_rs.setCursorType(AdoEnums.CursorType.STATIC);
m_rs.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
m_rs.setLockType(AdoEnums.LockType.OPTIMISTIC);
m_rs.open();
dataNavigator.setDataSource(m_rs);
}
void initializeBindings()
{
try
{
m_dataBinder = new DataBinder(m_rs);
m_dataBinder.setBindings(new DataBinding[]
{
new DataBinding( editBook,"Text","Book"),
new DataBinding( editBookTitle,"Text","BookTitle"),
new DataBinding( editChapter,"Text","Chapter"),
new DataBinding( editVerse,"Text","Verse"),
new DataBinding( editTextData,"Text","TextData")
});
}
catch (Exception e)
{
handleADOException( e );
}
}
void handleADOException(Exception e)
{
e.printStackTrace();
MessageBox.show( e.toString(), "Book"
);
}
/**
* NOTE: The following code is required by
the Visual J++ form
* designer. It can be modified using the
form editor. Do not
* modify it using the code editor.
*/
Container components = new Container();
Label labelBook = new Label();
Edit editBook = new Edit();
Label labelBookTitle = new Label();
Edit editBookTitle = new Edit();
Label labelChapter = new Label();
Edit editChapter = new Edit();
Label labelVerse = new Label();
Edit editVerse = new Edit();
Label labelTextData = new Label();
Edit editTextData = new Edit();
Button btnClose = new Button();
Panel panel1 = new Panel(components);
DataNavigator dataNavigator = new
DataNavigator();
private void initForm()
{
this.setBackColor(Color.CONTROL);
this.setLocation(new Point(7, 7));
this.setTabIndex(-1);
this.setTabStop(true);
this.setText("Book");
this.setAutoScaleBaseSize(13);
this.setAutoScroll(true);
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
this.setSize(new Point(420, 240));
this.setClientSize(new Point(420, 240));
labelBook.setBackColor (Color.CONTROL);
labelBook.setTabIndex ( 0 );
labelBook.setText ("Book" );
labelBook.setLocation (new Point ( 10, 20
) );
labelBook.setSize (new Point ( 100, 20 )
);
editBook.setBackColor (Color.WINDOW);
editBook.setTabIndex ( 1 );
editBook.setText ("Book" );
editBook.setLocation (new Point ( 120, 20
) );
editBook.setCursor (Cursor.IBEAM);
editBook.setAnchor(ControlAnchor.TOPLEFTRIGHT);
editBook.setSize (new Point ( 280, 20 ) );
editBook.setMultiline(true);
labelBookTitle.setBackColor (Color.CONTROL);
labelBookTitle.setTabIndex ( 2 );
labelBookTitle.setText ("BookTitle"
);
labelBookTitle.setLocation (new Point (
10, 50 ) );
labelBookTitle.setSize (new Point ( 100,
20 ) );
editBookTitle.setBackColor (Color.WINDOW);
editBookTitle.setTabIndex ( 3 );
editBookTitle.setText ("BookTitle"
);
editBookTitle.setLocation (new Point (
120, 50 ) );
editBookTitle.setCursor (Cursor.IBEAM);
editBookTitle.setAnchor(ControlAnchor.TOPLEFTRIGHT);
editBookTitle.setSize (new Point ( 280,
20 ) );
editBookTitle.setMultiline(true);
labelChapter.setBackColor (Color.CONTROL);
labelChapter.setTabIndex ( 4 );
labelChapter.setText ("Chapter"
);
labelChapter.setLocation (new Point ( 10,
80 ) );
labelChapter.setSize (new Point ( 100, 20
) );
editChapter.setBackColor (Color.WINDOW);
editChapter.setTabIndex ( 5 );
editChapter.setText ("Chapter"
);
editChapter.setLocation (new Point ( 120,
80 ) );
editChapter.setCursor (Cursor.IBEAM);
editChapter.setAnchor(ControlAnchor.TOPLEFTRIGHT);
editChapter.setSize (new Point ( 280, 20
) );
editChapter.setMultiline(true);
labelVerse.setBackColor (Color.CONTROL);
labelVerse.setTabIndex ( 6 );
labelVerse.setText ("Verse" );
labelVerse.setLocation (new Point ( 10,
110 ) );
labelVerse.setSize (new Point ( 100, 20 )
);
editVerse.setBackColor (Color.WINDOW);
editVerse.setTabIndex ( 7 );
editVerse.setText ("Verse" );
editVerse.setLocation (new Point ( 120,
110 ) );
editVerse.setCursor (Cursor.IBEAM);
editVerse.setAnchor(ControlAnchor.TOPLEFTRIGHT);
editVerse.setSize (new Point ( 280, 20 )
);
editVerse.setMultiline(true);
labelTextData.setBackColor (Color.CONTROL);
labelTextData.setTabIndex ( 8 );
labelTextData.setText ("TextData"
);
labelTextData.setLocation (new Point ( 10,
140 ) );
labelTextData.setSize (new Point ( 100,
20 ) );
editTextData.setBackColor (Color.WINDOW);
editTextData.setTabIndex ( 9 );
editTextData.setText ("TextData"
);
editTextData.setLocation (new Point ( 120,
140 ) );
editTextData.setCursor (Cursor.IBEAM);
editTextData.setAnchor(ControlAnchor.TOPLEFTRIGHT);
editTextData.setSize (new Point ( 280, 20
) );
editTextData.setMultiline(true);
editTextData.setScrollBars(ScrollBars.VERTICAL);
panel1.setDock(ControlDock.BOTTOM);
panel1.setLocation(new Point(0, 170));
panel1.setSize(new Point(420, 50));
panel1.setTabIndex(10);
btnClose.setLocation(new Point(175, 8));
btnClose.setSize(new Point(70, 30));
btnClose.setTabIndex(11);
btnClose.setTabStop(true);
btnClose.setText("&Close");
btnClose.addOnClick(new EventHandler(this.btnClose_Click));
dataNavigator.setDock(ControlDock.BOTTOM);
dataNavigator.setLocation(new Point(10,
210));
dataNavigator.setSize(new Point(400, 20));
dataNavigator.setTabIndex(12);
dataNavigator.setTabStop(false);
dataNavigator.setText("");
this.setNewControls(new Control[] {
dataNavigator,
btnClose,
panel1,
labelBook,
editBook,
labelBookTitle,
editBookTitle,
labelChapter,
editChapter,
labelVerse,
editVerse,
labelTextData,
editTextData
});
panel1.setNewControls(new Control[] {
btnClose
});
}
//NOTE: End of form designer support code.
/**
* The main entry point for the
application.
*
* @param args Array of parameters passed
to the application
* via the command line.
*/
public static void main(String args[])
{
Application.run( new Book() );
}
} |