home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
LocatorFrame.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
109 lines
/*
* Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland as part
* of a Borland product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
*/
package borland.samples.tutorial.dataset.locator;
// AWT imports
import java.awt.*;
import java.awt.event.*;
// JBCL imports
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import borland.sql.dataset.*;
import borland.jbcl.dataset.*;
// JBCL Frame
public class LocatorFrame extends DecoratedFrame
{
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
Label label1 = new Label();
TextField textField1 = new TextField();
Label label2 = new Label();
LocatorControl locatorControl1 = new LocatorControl();
GridControl gridControl1 = new GridControl();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
BevelPanel bevelPanel1 = new BevelPanel();
BorderLayout borderLayout1 = new BorderLayout();
StatusBar statusBar1 = new StatusBar();
Column column1 = new Column();
public LocatorFrame() {
try {
jbInit();
}
catch (Exception x) {
// handle exceptions here
}
}
private void jbInit() throws Exception {
gridControl1.setDataSet(queryDataSet1);
database1.setConnection(new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:dataset tutorial", "SYSDBA", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
queryDataSet1.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "select * from employee", null, true, Load.ALL));
label1.setText("Column to locate");
textField1.addKeyListener(new LocatorFrame_textField1_KeyAdapter(this));
label2.setText("Value to locate");
locatorControl1.setDataSet(queryDataSet1);
label3.setText("Name the column on which to search");
label4.setText("Then specify the exact value you want to locate");
label5.setText("(Press {ENTER} after each of the above items)");
statusBar1.setDataSet(queryDataSet1);
column1.setColumnName("HIRE_DATE");
column1.setDisplayMask("MM/dd/yy");
column1.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
queryDataSet1.setColumns(new Column[] {column1});
this.setLayout(borderLayout1);
this.setTitle("LocatorControl Application");
bevelPanel1.add(label1, new XYConstraints(18, 3, 134, 22));
bevelPanel1.add(textField1, new XYConstraints(18, 28, 184, 23));
bevelPanel1.add(label2, new XYConstraints(21, 62, 94, 23));
bevelPanel1.add(locatorControl1, new XYConstraints(18, 88, 187, 26));
bevelPanel1.add(label3, new XYConstraints(227, 27, 221, 23));
bevelPanel1.add(label4, new XYConstraints(227, 55, 286, -1));
bevelPanel1.add(label5, new XYConstraints(227, 82, 295, -1));
this.add(bevelPanel1, BorderLayout.NORTH);
this.add(gridControl1, BorderLayout.CENTER);
this.add(statusBar1, BorderLayout.SOUTH);
}
void textField1_keyPressed(java.awt.event.KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
locatorControl1.setColumnName(textField1.getText());
locatorControl1.requestFocus();
}
}
}
class LocatorFrame_textField1_KeyAdapter extends KeyAdapter {
LocatorFrame adaptee;
LocatorFrame_textField1_KeyAdapter(LocatorFrame adaptee) {
this.adaptee = adaptee;
}
public void keyPressed(java.awt.event.KeyEvent e) {
adaptee.textField1_keyPressed(e);
}
}