home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / BasicResolveFrame.java < prev    next >
Encoding:
Java Source  |  1997-07-12  |  2.9 KB  |  79 lines

  1. package borland.samples.tutorial.dataset.basicresolve;
  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.  
  9. public class BasicResolveFrame extends DecoratedFrame {
  10.   BorderLayout borderLayout1 = new BorderLayout();
  11.   BevelPanel bevelPanel1 = new BevelPanel();
  12.   StatusBar statusBar = new StatusBar();
  13.   GridControl gridControl1 = new GridControl();
  14.   NavigatorControl navigatorControl1 = new NavigatorControl();
  15.   ButtonControl buttonControl1 = new ButtonControl();
  16.   Database database1 = new Database();
  17.   QueryDataSet queryDataSet1 = new QueryDataSet();
  18.   BorderLayout borderLayout2 = new BorderLayout();
  19.   BevelPanel bevelPanel2 = new BevelPanel();
  20.   FlowLayout flowLayout1 = new FlowLayout();
  21.  
  22.   //Construct the frame
  23.   public BasicResolveFrame() {
  24.     try {
  25.       jbInit();
  26.     }
  27.     catch (Exception e) {
  28.       borland.jbcl.util.Diagnostic.printStackTrace(e);
  29.     }
  30.   }
  31.  
  32.   //Component initialization
  33.   public void jbInit() throws Exception{
  34.     this.setLayout(borderLayout1);
  35.     this.setSize(new Dimension(551, 398));
  36.     this.setTitle("Basic Resolving");
  37.     bevelPanel1.setLayout(borderLayout2);
  38.     statusBar.setDataSet(queryDataSet1);
  39.     gridControl1.setDataSet(queryDataSet1);
  40.     navigatorControl1.setDataSet(queryDataSet1);
  41.     buttonControl1.setLabel("Save Changes");
  42.     buttonControl1.addActionListener(new BasicResolveFrame_buttonControl1_actionAdapter(this));
  43.     database1.setConnection(new borland.jbcl.dataset.ConnectionDescriptor("jdbc:odbc:DataSet Tutorial", "SYSDBA", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
  44.     queryDataSet1.setQuery(new borland.jbcl.dataset.QueryDescriptor(database1, "select * from employee", null, true, false));
  45.     bevelPanel2.setLayout(flowLayout1);
  46.     this.add(statusBar, BorderLayout.SOUTH);
  47.     this.add(bevelPanel1, BorderLayout.CENTER);
  48.     bevelPanel1.add(gridControl1, BorderLayout.CENTER);
  49.     bevelPanel1.add(navigatorControl1, BorderLayout.NORTH);
  50.     bevelPanel1.add(bevelPanel2, BorderLayout.SOUTH);
  51.     bevelPanel2.add(buttonControl1, null);
  52.   }
  53.  
  54.   
  55.   void buttonControl1_actionPerformed(ActionEvent e) {
  56.   try {
  57.            database1.saveChanges(queryDataSet1); //, UpdateMode.CHANGED_COLUMNS);
  58.            System.out.println("Save changes succeeded");
  59.        }
  60.        catch (Exception ex) {
  61.      // displays the exception on the StatusBar if the application includes one,
  62.      // or displays an error dialog if there isn't 
  63.          DataSetException.handleException(ex);  }
  64.   }
  65. }
  66.  
  67. class BasicResolveFrame_buttonControl1_actionAdapter implements java.awt.event.ActionListener {
  68.   BasicResolveFrame adaptee;
  69.  
  70.   BasicResolveFrame_buttonControl1_actionAdapter(BasicResolveFrame adaptee) {
  71.     this.adaptee = adaptee;
  72.   }
  73.  
  74.   public void actionPerformed(ActionEvent e) {
  75.     adaptee.buttonControl1_actionPerformed(e);
  76.   }
  77. }
  78.  
  79.