How to include and use a JavaBean component on a form.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server | |
See the chapter on using utility classes, JAR files, and JavaBeans in the Programmer's Guide |
This example also includes information on where to store the bean's jar file and how to use its methods to perform tasks.
The following describes how to add a JavaBean to a form:
As with other controls in SilverStream forms, you can modify the properties of a JavaBean by right-clicking it and selecting Properties to use the Properties dialog box.
In this bean example, one of the bean's properties you can modify is the selected background color. In setting this property, you are setting the background color of the user-selected date so that each time the user clicks a date in the calendar, the clicked date's color changes from the default background color to this color. Set this property as follows:
The following code shows how to get the user-selected date of a calendar JavaBean and display it in a text field.
private void handle_btnGetCurrent_actionPerformed(ActionEvent evt)
{
GregorianCalendar current;
// Get the current date.
current = AgCalendar.getCurrentDate();
// Set the field on the form with the current date.
// Need to subtract 1900 from the GregorianDate because
// the field on the form is a java.sql.Data which is 1900
// based.
fldCurrentDate.setValue( new
java.sql.Date(current.get(Calendar.YEAR) - 1900,
current.get(Calendar.MONTH), current.get(Calendar.DATE)));
}
getCurrentDate()
returns the GregorianCalendar
containing the selected date.
GregorianCalendar
's year, month, and date (the number representing the day of the month). Note the following:
fldCurrentDate.setValue
sets the text field to the selected date.