![]() ![]() |
This tutorial provides instructions for writing a set of event handlers. The tutorial assumes that you have a basic report design based on the Classic Models, Inc. Sample Database. The only requirement of the starting report design is that it contains a table of customers with a column for the customer name. In this tutorial you count the customers whose names contain the string "Mini" and display the result in a pop-up window.
In this tutorial, you perform the following tasks:
Open a report design that uses the Classic Car sample database and displays a table of customer names.
In order to count the number of customers whose names contain "Mini", you must first declare a global counter and set its value to zero. You conditionally incremented this counter in the Table.onRow( ) method. The Table.onStart( ) method is the most appropriate place to do this because Table.onStart( ) executes before any rows are retrieved.
Do the following tasks:
To count the number of customers with "Mini" in their name, you must examine each customer's name and add one to the counter for every occurrence. A logical place to do this is in the Table.onRow( ) method, which is executed upon every retrieval of a row of data from the data source.
To display the count of customers with "Mini" in their name, you must insert code in a method that runs at the completion of processing the table. The place to do this is in the Table.onFinish( ) method.
importPackage(Packages.javax.swing); frame = new JFrame("Count of Minis = " + countOfMinis); frame.setBounds(310, 220, 300, 20); frame.show();
![]() ![]() |