home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
LocatorFrame.java
< prev
next >
Wrap
Text File
|
1997-07-09
|
4KB
|
92 lines
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.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();
public LocatorFrame() {
try {
jbInit();
}
catch (Exception x) {
// handle exceptions here
}
}
public void jbInit() throws Exception {
database1.setConnection(new borland.jbcl.dataset.ConnectionDescriptor("jdbc:odbc:dataset tutorial", "SYSDBA", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
queryDataSet1.setQuery(new borland.jbcl.dataset.QueryDescriptor(database1, "select * from employee", null, true, false));
label1.setText("Column to locate");
textField1.addKeyListener(new LocatorFrame_textField1_KeyAdapter(this));
label2.setText("Value to locate");
locatorControl1.setDataSet(queryDataSet1);
gridControl1.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);
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);
this.pack();
//Center the window
Dimension dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dimFrame = this.getPreferredSize();
if(dimFrame.height > dimScreen.height) dimFrame.height = dimScreen.height;
if(dimFrame.width > dimScreen.width) dimFrame.width = dimScreen.width;
this.setBounds( (dimScreen.width - dimFrame.width) / 2, (dimScreen.height - dimFrame.height) / 2, dimFrame.width, dimFrame.height);
}
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);
}
}