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

📄 relatedtablewriteframe.java~3~

📁 jbuilder2006一书的所有源代码
💻 JAVA~3~
字号:
package relation;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;public class RelatedTableWriteFrame extends JFrame {  JPanel contentPane;  BorderLayout borderLayout1 = new BorderLayout();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  QueryDataSet queryDataSet2 = new QueryDataSet();  JSplitPane jSplitPane1 = new JSplitPane();  JPanel jPanel1 = new JPanel();  BorderLayout borderLayout2 = new BorderLayout();  JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  JPanel jPanel2 = new JPanel();  BorderLayout borderLayout3 = new BorderLayout();  JdbNavToolBar jdbNavToolBar2 = new JdbNavToolBar();  TableScrollPane tableScrollPane2 = new TableScrollPane();  JdbTable jdbTable2 = new JdbTable();  public RelatedTableWriteFrame() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(borderLayout1);    this.setSize(new Dimension(400, 300));    this.setTitle("关系数据表的存储应用");    //建立与SQLServer的books数据库的联接    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(        "jdbc:microsoft:sqlserver://bemyfriend:1433;DatabaseName=books", "sa",        "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));    //取得bookcategory数据表的记录    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(        database1, "select * from bookcategory", null, true, Load.ALL));    //取得books数据表的记录    queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(        database1, "select * from books", null, true, Load.ALL));    //定义一对多关系    queryDataSet2.setMasterLink(new com.borland.dx.dataset.MasterLinkDescriptor(        queryDataSet1, new String[] {"id"}        , new String[] {"categoryId"}        , false, false, false));    //设置面板布局    jPanel1.setLayout(borderLayout2);    jPanel2.setLayout(borderLayout3);    //设置分隔框的对齐方式    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);    //设置数据源    jdbNavToolBar1.setDataSet(queryDataSet1);    jdbTable1.setDataSet(queryDataSet1);    jdbNavToolBar2.setDataSet(queryDataSet2);    jdbTable2.setDataSet(queryDataSet2);    //设置分隔框的分隔条位置    jSplitPane1.setDividerLocation(120);    //为分隔框加入面板    jSplitPane1.add(jPanel1, JSplitPane.TOP);    jSplitPane1.add(jPanel2, JSplitPane.BOTTOM);    //为面板1加入工具栏和表格滚动框    jPanel1.add(jdbNavToolBar1, BorderLayout.NORTH);    jPanel1.add(tableScrollPane1, BorderLayout.CENTER);    //为面板2加入工具栏和表格滚动框    jPanel2.add(jdbNavToolBar2, BorderLayout.NORTH);    jPanel2.add(tableScrollPane2, BorderLayout.CENTER);    tableScrollPane2.getViewport().add(jdbTable2, null);    tableScrollPane1.getViewport().add(jdbTable1, null);    contentPane.add(jSplitPane1, BorderLayout.CENTER);  }  protected void processWindowEvent(WindowEvent e) {    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }}

⌨️ 快捷键说明

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