⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbapplet.java~

📁 <Java编程精选集锦>随书源码
💻 JAVA~
字号:
package dbapplet;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dx.dataset.*;import com.borland.dbswing.*;import com.borland.jbcl.layout.*;public class DBApplet extends JApplet {  boolean isStandalone = false;  TableDataSet tableDataSet1 = new TableDataSet();  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel1 = new JLabel();  JTextField dns = new JTextField();  JLabel jLabel2 = new JLabel();  JTextField sql = new JTextField();  JButton jButton1 = new JButton();  JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel();  JLabel jLabel3 = new JLabel();  JTextField userName = new JTextField();  JLabel jLabel4 = new JLabel();  JTextField password = new JTextField();  //Get a parameter value  public String getParameter(String key, String def) {    return isStandalone ? System.getProperty(key, def) :      (getParameter(key) != null ? getParameter(key) : def);  }  //Construct the applet  public DBApplet() {  }  //Initialize the applet  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    jLabel1.setText("DNS");    this.setSize(new Dimension(400,300));    this.getContentPane().setLayout(xYLayout1);    dns.setText("Authors");    jLabel2.setText("SQL");    sql.setText("select * from authors");    jButton1.setText("OK");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jdbStatusLabel1.setText("jdbStatusLabel1");    jdbNavToolBar1.setButtonStateInsert(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStateDelete(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStatePost(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStateCancel(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStateDitto(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStateSave(JdbNavToolBar.HIDDEN);    jdbNavToolBar1.setButtonStateRefresh(JdbNavToolBar.HIDDEN);    jLabel3.setText("UserName");    jLabel4.setText("Password");    this.getContentPane().add(jLabel1, new XYConstraints(15, 8, 58, 16));    this.getContentPane().add(tableScrollPane1, new XYConstraints(31, 144, 357, 129));    this.getContentPane().add(jdbStatusLabel1, new XYConstraints(32, 277, 357, 20));    this.getContentPane().add(jLabel2, new XYConstraints(15, 55, 49, -1));    this.getContentPane().add(dns, new XYConstraints(47, 9, 131, 23));    this.getContentPane().add(sql, new XYConstraints(47, 47, 132, 24));    this.getContentPane().add(jButton1, new XYConstraints(42, 92, 64, 40));    this.getContentPane().add(jdbNavToolBar1, new XYConstraints(141, 91, 241, 39));    this.getContentPane().add(jLabel3, new XYConstraints(188, 15, 67, 14));    this.getContentPane().add(userName, new XYConstraints(262, 12, 110, 20));    this.getContentPane().add(jLabel4, new XYConstraints(187, 52, 69, 21));    this.getContentPane().add(password, new XYConstraints(261, 53, 113, -1));    tableScrollPane1.getViewport().add(jdbTable1, null);  }  //Get Applet information  public String getAppletInfo() {    return "Applet Information";  }  //Get parameter info  public String[][] getParameterInfo() {    return null;  }  //static initializer for setting look & feel  static {    try {      //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());      //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());    }    catch(Exception e) {    }  }  void jButton1_actionPerformed(ActionEvent e) {    try{    //接受客户输入的查询条件      String queryText = "dns=" + dns.getText();      queryText += "&sql="+sql.getText();      if (userName.getText().length() > 0)         queryText += "&username=" + userName.getText();      if (password.getText().length() > 0)         queryText += "&password=" + password.getText();      //设定Provider      ClientProvider clientProvider = new ClientProvider(queryText);      tableDataSet1.close();      tableDataSet1.setProvider(clientProvider);      //绑定具有数据感应能力的Beans      jdbStatusLabel1.setDataSet(tableDataSet1);      jdbNavToolBar1.setDataSet(tableDataSet1);      jdbTable1.setDataSet(tableDataSet1);    }    catch(DataSetException ex){      System.out.println(ex.getMessage());    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -