home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / AggCalc_Frame.java < prev    next >
Text File  |  1997-07-12  |  3KB  |  76 lines

  1. package borland.samples.tutorial.dataset.aggcalc;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import borland.jbcl.control.*;
  6. import borland.jbcl.layout.*;
  7. import borland.jbcl.dataset.*;
  8. import borland.jbcl.util.*;
  9.  
  10. public class AggCalc_Frame extends DecoratedFrame {
  11.   BorderLayout borderLayout1 = new BorderLayout();
  12.   BevelPanel bevelPanel1 = new BevelPanel();
  13.   Database database1 = new Database();
  14.   QueryDataSet queryDataSet1 = new QueryDataSet();
  15.   GridControl gridControl1 = new GridControl();
  16.   TextFieldControl textFieldControl1 = new TextFieldControl();
  17.   Column column1 = new Column();
  18.   LabelControl labelControl1 = new LabelControl();
  19.   Column column2 = new Column();
  20.   Column column3 = new Column();
  21.   BorderLayout borderLayout2 = new BorderLayout();
  22.   BevelPanel bevelPanel2 = new BevelPanel();
  23.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  24.   Column column4 = new Column();
  25.  
  26.   //Construct the frame
  27.   public AggCalc_Frame() {
  28.     try {
  29.       jbInit();
  30.           }
  31.     catch (Exception e) {
  32.       borland.jbcl.util.Diagnostic.printStackTrace(e);
  33.     }
  34.   }
  35.  
  36.   //Component initialization
  37.   public void jbInit() throws Exception{
  38.     this.setLayout(borderLayout1);
  39.     this.setSize(new Dimension(540, 359));
  40.     this.setTitle("Aggregate Calculated Column");
  41.     bevelPanel1.setLayout(borderLayout2);
  42.     database1.setConnection(new borland.jbcl.dataset.ConnectionDescriptor("jdbc:odbc:dataset tutorial", "sysdba", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver;borland.interclient.Driver"));
  43.     queryDataSet1.setQuery(new borland.jbcl.dataset.QueryDescriptor(database1, "select cust_no, PO_NUMBER, SHIP_DATE , TOTAL_VALUE  from sales", null, true, false));
  44.     gridControl1.setDataSet(queryDataSet1);
  45.     gridControl1.setPreferredSize(new Dimension(400, 500));
  46.     textFieldControl1.setColumnName("GROUP_TOTAL");
  47.     textFieldControl1.setDataSet(queryDataSet1);
  48.     this.add(bevelPanel1, BorderLayout.CENTER);
  49.     bevelPanel1.add(gridControl1, BorderLayout.NORTH);
  50.     this.add(bevelPanel2, BorderLayout.SOUTH);
  51.     bevelPanel2.add(labelControl1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 0.0
  52.             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  53.     bevelPanel2.add(textFieldControl1, new GridBagConstraints2(1, 0, 1, 1, 2.0, 0.0
  54.             ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  55.     column1.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
  56.     column1.setCaption("GROUP_TOTAL");
  57.     column1.setColumnName("GROUP_TOTAL");
  58.     column1.setDataType(borland.jbcl.util.Variant.BIGDECIMAL);
  59.     column1.setAgg(new AggDescriptor(new String[] { "cust_no" }, "TOTAL_VALUE",
  60.       new SumAggOperator()));
  61.     labelControl1.setText("Customer Total Sales:");
  62.     column2.setColumnName("PO_NUMBER");
  63.     column2.setDataType(borland.jbcl.util.Variant.STRING);
  64.     column3.setColumnName("CUST_NO");
  65.     column3.setDataType(borland.jbcl.util.Variant.INT);
  66.     column4.setColumnName("SHIP_DATE");
  67.     column4.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
  68.     bevelPanel2.setLayout(gridBagLayout1);
  69.     queryDataSet1.setColumns(new Column[] {column1, column3, column2, column4});
  70.   }
  71.  
  72. }
  73.  
  74.  
  75.  
  76.