📄 frame1.java~15~
字号:
package sql;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.lang.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; Database database1 = new Database(); QueryDataSet queryDataSet1 = new QueryDataSet(); TableScrollPane tableScrollPane1 = new TableScrollPane(); JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar(); JdbTable jdbTable1 = new JdbTable(); TextArea textArea1 = new TextArea(); Label label1 = new Label(); Button button1 = new Button(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(null); this.setSize(new Dimension(492, 371)); this.setTitle("SQL语言的使用"); tableScrollPane1.setBounds(new Rectangle(24, 63, 441, 133)); jdbNavToolBar1.setDataSet(queryDataSet1); jdbNavToolBar1.setBounds(new Rectangle(26, 17, 441, 40)); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:borland:dslocal:E:\\Program Files\\Jbuilder\\samples\\JDataStore\\datastores\\employee.jds", "username", "username", false, "com.borland.datastore.jdbc.DataStoreDriver")); queryDataSet1.setTableName("EMPLOYEE"); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT EMP_NO, FULL_NAME, HIRE_DATE, DEPT_NO, JOB_COUNTRY, SALARY " + "FROM EMPLOYEE", null, true, Load.ALL)); jdbTable1.setDataSet(queryDataSet1); textArea1.setText("textArea1"); textArea1.setBounds(new Rectangle(29, 233, 436, 46)); label1.setText("请输入SQL语句:"); label1.setBounds(new Rectangle(25, 206, 104, 18)); button1.setLabel("查询"); button1.setBounds(new Rectangle(183, 307, 131, 29)); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); contentPane.add(jdbNavToolBar1, null); contentPane.add(tableScrollPane1, null); contentPane.add(textArea1, null); contentPane.add(label1, null); contentPane.add(button1, null); tableScrollPane1.getViewport().add(jdbTable1, null); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void button1_actionPerformed(ActionEvent e) { queryDataSet1.close();//一个数据集不能同时打开再次,所以要先关闭 queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, textArea1.getText(), null, true, Load.ALL)); jdbTable1.setDataSet(queryDataSet1); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -