home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-12 | 3.2 KB | 76 lines |
- package borland.samples.tutorial.dataset.aggcalc;
-
- import java.awt.*;
- import java.awt.event.*;
- import borland.jbcl.control.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.dataset.*;
- import borland.jbcl.util.*;
-
- public class AggCalc_Frame extends DecoratedFrame {
- BorderLayout borderLayout1 = new BorderLayout();
- BevelPanel bevelPanel1 = new BevelPanel();
- Database database1 = new Database();
- QueryDataSet queryDataSet1 = new QueryDataSet();
- GridControl gridControl1 = new GridControl();
- TextFieldControl textFieldControl1 = new TextFieldControl();
- Column column1 = new Column();
- LabelControl labelControl1 = new LabelControl();
- Column column2 = new Column();
- Column column3 = new Column();
- BorderLayout borderLayout2 = new BorderLayout();
- BevelPanel bevelPanel2 = new BevelPanel();
- GridBagLayout gridBagLayout1 = new GridBagLayout();
- Column column4 = new Column();
-
- //Construct the frame
- public AggCalc_Frame() {
- try {
- jbInit();
- }
- catch (Exception e) {
- borland.jbcl.util.Diagnostic.printStackTrace(e);
- }
- }
-
- //Component initialization
- public void jbInit() throws Exception{
- this.setLayout(borderLayout1);
- this.setSize(new Dimension(540, 359));
- this.setTitle("Aggregate Calculated Column");
- bevelPanel1.setLayout(borderLayout2);
- database1.setConnection(new borland.jbcl.dataset.ConnectionDescriptor("jdbc:odbc:dataset tutorial", "sysdba", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver;borland.interclient.Driver"));
- queryDataSet1.setQuery(new borland.jbcl.dataset.QueryDescriptor(database1, "select cust_no, PO_NUMBER, SHIP_DATE , TOTAL_VALUE from sales", null, true, false));
- gridControl1.setDataSet(queryDataSet1);
- gridControl1.setPreferredSize(new Dimension(400, 500));
- textFieldControl1.setColumnName("GROUP_TOTAL");
- textFieldControl1.setDataSet(queryDataSet1);
- this.add(bevelPanel1, BorderLayout.CENTER);
- bevelPanel1.add(gridControl1, BorderLayout.NORTH);
- this.add(bevelPanel2, BorderLayout.SOUTH);
- bevelPanel2.add(labelControl1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(textFieldControl1, new GridBagConstraints2(1, 0, 1, 1, 2.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- column1.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
- column1.setCaption("GROUP_TOTAL");
- column1.setColumnName("GROUP_TOTAL");
- column1.setDataType(borland.jbcl.util.Variant.BIGDECIMAL);
- column1.setAgg(new AggDescriptor(new String[] { "cust_no" }, "TOTAL_VALUE",
- new SumAggOperator()));
- labelControl1.setText("Customer Total Sales:");
- column2.setColumnName("PO_NUMBER");
- column2.setDataType(borland.jbcl.util.Variant.STRING);
- column3.setColumnName("CUST_NO");
- column3.setDataType(borland.jbcl.util.Variant.INT);
- column4.setColumnName("SHIP_DATE");
- column4.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
- bevelPanel2.setLayout(gridBagLayout1);
- queryDataSet1.setColumns(new Column[] {column1, column3, column2, column4});
- }
-
- }
-
-
-
-