当前位置: 技术问答>java相关
jb7里没有没象delphi或vb那样的datagrid控件?
来源: 互联网 发布时间:2015-10-29
本文导语: jb7里没有没象delphi或vb那样的datagrid控件?我看了一下有一个datasetview挺象的,但拖过来什么也没有呀,是不是行列什么的,都得用代码加呀?或者不是这个东东,更或者根本就没有这样的东东(不太可能吧),大家帮忙...
jb7里没有没象delphi或vb那样的datagrid控件?我看了一下有一个datasetview挺象的,但拖过来什么也没有呀,是不是行列什么的,都得用代码加呀?或者不是这个东东,更或者根本就没有这样的东东(不太可能吧),大家帮忙,thank you
|
有啊!~
==================================================================
import com.borland.dx.dataset.*;
import javax.swing.border.*;
/**
*
*
*
*
* @author unascribed
* @version 1.0
*/
public class FrmProvider extends JFrame {
private QueryDataSet queryDataSet1 = new QueryDataSet();
private Database database1 ;
private JPanel jPanel1 = new JPanel();
private JdbTextField jdbTextField1 = new JdbTextField();
private XYLayout xYLayout2 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JdbTextField jdbTextField2 = new JdbTextField();
private JLabel jLabel2 = new JLabel();
private JdbTextField jdbTextField3 = new JdbTextField();
private JLabel jLabel3 = new JLabel();
private JdbTextField jdbTextField4 = new JdbTextField();
private JLabel jLabel4 = new JLabel();
private JdbTextField jdbTextField5 = new JdbTextField();
private JLabel jLabel5 = new JLabel();
private JdbTextField jdbTextField6 = new JdbTextField();
private JLabel jLabel6 = new JLabel();
private JLabel jLabel7 = new JLabel();
private JdbTextField jdbTextField7 = new JdbTextField();
private JLabel jLabel8 = new JLabel();
private JdbTextField jdbTextField8 = new JdbTextField();
private JLabel jLabel9 = new JLabel();
private JdbTextField jdbTextField9 = new JdbTextField();
private JLabel jLabel10 = new JLabel();
private JdbTextField jdbTextField10 = new JdbTextField();
private JLabel jLabel11 = new JLabel();
private JdbTextField jdbTextField11 = new JdbTextField();
private JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
private JdbTable jdbTable1 = new JdbTable();
private Column column1 = new Column();
private TitledBorder titledBorder1;
public FrmProvider() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public FrmProvider( Database Value)
{ database1=Value;
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
titledBorder1 = new TitledBorder("");
this.setTitle("供应商基本信息设置");
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:northwind", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
database1.setTransactionIsolation(java.sql.Connection.TRANSACTION_NONE);
database1.setDatabaseName("");
queryDataSet1.setResolvable(false);
queryDataSet1.setSchemaName("");
queryDataSet1.setSort(new com.borland.dx.dataset.SortDescriptor("", new String[] {"公司名称"}, new boolean[] {false, }, null, 0));
queryDataSet1.setTableName("供应商");
queryDataSet1.setAccumulateResults(true);
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT "供应商"."公司名称","供应商"."供应商ID","供应商"."联系人姓名","供应商"."联系人职务","供应商"."地址","供应商"."城市","供应商"."地区","供应商"." +
""邮政编码","供应商"."国家","供应商"."电话","供应商"."传真","供应商"."主页" FROM"供应商"", null, true, Load.ALL));
jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel1.setLayout(xYLayout2);
jdbTextField1.setText("jdbTextField1");
jdbTextField1.setColumnName("公司名称");
jdbTextField1.setDataSet(queryDataSet1);
jLabel1.setText("公司名称");
jdbTextField2.setText("jdbTextField2");
jdbTextField2.setColumnName("国家");
jdbTextField2.setDataSet(queryDataSet1);
jLabel2.setText("国家");
jdbTextField3.setText("jdbTextField3");
jdbTextField3.setColumnName("城市");
jdbTextField3.setDataSet(queryDataSet1);
jLabel3.setText("城市");
jdbTextField4.setText("jdbTextField4");
jdbTextField4.setColumnName("地区");
jdbTextField4.setDataSet(queryDataSet1);
jLabel4.setText("地区");
jdbTextField5.setText("jdbTextField5");
jdbTextField5.setColumnName("地址");
jdbTextField5.setDataSet(queryDataSet1);
jLabel5.setText("地址");
jdbTextField6.setText("jdbTextField6");
jdbTextField6.setColumnName("联系人姓名");
jdbTextField6.setDataSet(queryDataSet1);
jLabel6.setText("联系人");
jLabel7.setText("联系人职务");
jdbTextField7.setText("jdbTextField7");
jdbTextField7.setColumnName("联系人职务");
jdbTextField7.setDataSet(queryDataSet1);
jLabel8.setText("邮政编码");
jdbTextField8.setText("jdbTextField8");
jdbTextField8.setColumnName("邮政编码");
jdbTextField8.setDataSet(queryDataSet1);
jLabel9.setText("电话");
jdbTextField9.setText("jdbTextField9");
jdbTextField9.setColumnName("电话");
jdbTextField9.setDataSet(queryDataSet1);
jLabel10.setText("传真");
jdbTextField10.setText("jdbTextField10");
jdbTextField10.setColumnName("传真");
jdbTextField10.setDataSet(queryDataSet1);
jLabel11.setText("主页");
jdbTextField11.setText("jdbTextField11");
jdbTextField11.setColumnName("主页");
jdbTextField11.setDataSet(queryDataSet1);
jdbNavToolBar1.setDataSet(queryDataSet1);
jdbTable1.setBorder(titledBorder1);
jdbTable1.setColumnSelectionAllowed(true);
jdbTable1.setDataSet(queryDataSet1);
column1.setColumnName("供应商ID");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setExportDisplayMask("");
column1.setDefault("");
column1.setMax("");
column1.setMin("");
column1.setRowId(true);
column1.setSchemaName("");
column1.setSearchable(false);
column1.setResolvable(false);
column1.setTableName("");
column1.setVisible(com.borland.jb.util.TriStateProperty.TRUE);
column1.setServerColumnName("供应商ID");
column1.setSqlType(4);
queryDataSet1.setColumns(new Column[] {column1});
this.getContentPane().add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jdbTextField1, new XYConstraints(113, 10, 134, -1));
jPanel1.add(jdbTextField2, new XYConstraints(344, 8, 119, 23));
jPanel1.add(jLabel2, new XYConstraints(266, 14, 60, 17));
jPanel1.add(jdbTextField3, new XYConstraints(346, 41, 117, 23));
jPanel1.add(jLabel3, new XYConstraints(269, 43, 64, 20));
jPanel1.add(jdbTextField4, new XYConstraints(113, 40, 131, -1));
jPanel1.add(jdbTextField5, new XYConstraints(112, 72, 350, 23));
jPanel1.add(jdbTextField6, new XYConstraints(111, 103, 126, 23));
jPanel1.add(jLabel7, new XYConstraints(265, 106, 80, -1));
jPanel1.add(jdbTextField7, new XYConstraints(343, 103, 118, 24));
jPanel1.add(jLabel9, new XYConstraints(265, 139, 64, -1));
jPanel1.add(jdbTextField9, new XYConstraints(342, 135, 121, -1));
jPanel1.add(jLabel4, new XYConstraints(36, 43, 51, 22));
jPanel1.add(jLabel10, new XYConstraints(36, 168, 56, 23));
jPanel1.add(jLabel8, new XYConstraints(36, 139, 51, 23));
jPanel1.add(jLabel6, new XYConstraints(36, 104, 56, 20));
jPanel1.add(jLabel5, new XYConstraints(36, 76, 47, 22));
jPanel1.add(jLabel1, new XYConstraints(36, 16, 58, 19));
jPanel1.add(jdbTextField8, new XYConstraints(109, 135, 128, -1));
jPanel1.add(jdbTextField10, new XYConstraints(106, 170, 133, -1));
jPanel1.add(jdbTextField11, new XYConstraints(340, 167, 125, -1));
jPanel1.add(jLabel11, new XYConstraints(267, 168, 53, 23));
jPanel1.add(jdbNavToolBar1, new XYConstraints(1, 202, 526, 40));
this.getContentPane().add(jdbTable1, BorderLayout.CENTER);
}
}
===========================
上面得代码是我学习Java得时候使用JB7得时候使用Nortwind中文数据库得代码!可能不能运行,应为DataBase1没有实例话!你可以生成这个对象运行!
==================================================================
import com.borland.dx.dataset.*;
import javax.swing.border.*;
/**
*
Title:
*
Description:
*
Copyright: Copyright (c) 2002
*
Company:
* @author unascribed
* @version 1.0
*/
public class FrmProvider extends JFrame {
private QueryDataSet queryDataSet1 = new QueryDataSet();
private Database database1 ;
private JPanel jPanel1 = new JPanel();
private JdbTextField jdbTextField1 = new JdbTextField();
private XYLayout xYLayout2 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JdbTextField jdbTextField2 = new JdbTextField();
private JLabel jLabel2 = new JLabel();
private JdbTextField jdbTextField3 = new JdbTextField();
private JLabel jLabel3 = new JLabel();
private JdbTextField jdbTextField4 = new JdbTextField();
private JLabel jLabel4 = new JLabel();
private JdbTextField jdbTextField5 = new JdbTextField();
private JLabel jLabel5 = new JLabel();
private JdbTextField jdbTextField6 = new JdbTextField();
private JLabel jLabel6 = new JLabel();
private JLabel jLabel7 = new JLabel();
private JdbTextField jdbTextField7 = new JdbTextField();
private JLabel jLabel8 = new JLabel();
private JdbTextField jdbTextField8 = new JdbTextField();
private JLabel jLabel9 = new JLabel();
private JdbTextField jdbTextField9 = new JdbTextField();
private JLabel jLabel10 = new JLabel();
private JdbTextField jdbTextField10 = new JdbTextField();
private JLabel jLabel11 = new JLabel();
private JdbTextField jdbTextField11 = new JdbTextField();
private JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
private JdbTable jdbTable1 = new JdbTable();
private Column column1 = new Column();
private TitledBorder titledBorder1;
public FrmProvider() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public FrmProvider( Database Value)
{ database1=Value;
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
titledBorder1 = new TitledBorder("");
this.setTitle("供应商基本信息设置");
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:northwind", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
database1.setTransactionIsolation(java.sql.Connection.TRANSACTION_NONE);
database1.setDatabaseName("");
queryDataSet1.setResolvable(false);
queryDataSet1.setSchemaName("");
queryDataSet1.setSort(new com.borland.dx.dataset.SortDescriptor("", new String[] {"公司名称"}, new boolean[] {false, }, null, 0));
queryDataSet1.setTableName("供应商");
queryDataSet1.setAccumulateResults(true);
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT "供应商"."公司名称","供应商"."供应商ID","供应商"."联系人姓名","供应商"."联系人职务","供应商"."地址","供应商"."城市","供应商"."地区","供应商"." +
""邮政编码","供应商"."国家","供应商"."电话","供应商"."传真","供应商"."主页" FROM"供应商"", null, true, Load.ALL));
jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel1.setLayout(xYLayout2);
jdbTextField1.setText("jdbTextField1");
jdbTextField1.setColumnName("公司名称");
jdbTextField1.setDataSet(queryDataSet1);
jLabel1.setText("公司名称");
jdbTextField2.setText("jdbTextField2");
jdbTextField2.setColumnName("国家");
jdbTextField2.setDataSet(queryDataSet1);
jLabel2.setText("国家");
jdbTextField3.setText("jdbTextField3");
jdbTextField3.setColumnName("城市");
jdbTextField3.setDataSet(queryDataSet1);
jLabel3.setText("城市");
jdbTextField4.setText("jdbTextField4");
jdbTextField4.setColumnName("地区");
jdbTextField4.setDataSet(queryDataSet1);
jLabel4.setText("地区");
jdbTextField5.setText("jdbTextField5");
jdbTextField5.setColumnName("地址");
jdbTextField5.setDataSet(queryDataSet1);
jLabel5.setText("地址");
jdbTextField6.setText("jdbTextField6");
jdbTextField6.setColumnName("联系人姓名");
jdbTextField6.setDataSet(queryDataSet1);
jLabel6.setText("联系人");
jLabel7.setText("联系人职务");
jdbTextField7.setText("jdbTextField7");
jdbTextField7.setColumnName("联系人职务");
jdbTextField7.setDataSet(queryDataSet1);
jLabel8.setText("邮政编码");
jdbTextField8.setText("jdbTextField8");
jdbTextField8.setColumnName("邮政编码");
jdbTextField8.setDataSet(queryDataSet1);
jLabel9.setText("电话");
jdbTextField9.setText("jdbTextField9");
jdbTextField9.setColumnName("电话");
jdbTextField9.setDataSet(queryDataSet1);
jLabel10.setText("传真");
jdbTextField10.setText("jdbTextField10");
jdbTextField10.setColumnName("传真");
jdbTextField10.setDataSet(queryDataSet1);
jLabel11.setText("主页");
jdbTextField11.setText("jdbTextField11");
jdbTextField11.setColumnName("主页");
jdbTextField11.setDataSet(queryDataSet1);
jdbNavToolBar1.setDataSet(queryDataSet1);
jdbTable1.setBorder(titledBorder1);
jdbTable1.setColumnSelectionAllowed(true);
jdbTable1.setDataSet(queryDataSet1);
column1.setColumnName("供应商ID");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setExportDisplayMask("");
column1.setDefault("");
column1.setMax("");
column1.setMin("");
column1.setRowId(true);
column1.setSchemaName("");
column1.setSearchable(false);
column1.setResolvable(false);
column1.setTableName("");
column1.setVisible(com.borland.jb.util.TriStateProperty.TRUE);
column1.setServerColumnName("供应商ID");
column1.setSqlType(4);
queryDataSet1.setColumns(new Column[] {column1});
this.getContentPane().add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jdbTextField1, new XYConstraints(113, 10, 134, -1));
jPanel1.add(jdbTextField2, new XYConstraints(344, 8, 119, 23));
jPanel1.add(jLabel2, new XYConstraints(266, 14, 60, 17));
jPanel1.add(jdbTextField3, new XYConstraints(346, 41, 117, 23));
jPanel1.add(jLabel3, new XYConstraints(269, 43, 64, 20));
jPanel1.add(jdbTextField4, new XYConstraints(113, 40, 131, -1));
jPanel1.add(jdbTextField5, new XYConstraints(112, 72, 350, 23));
jPanel1.add(jdbTextField6, new XYConstraints(111, 103, 126, 23));
jPanel1.add(jLabel7, new XYConstraints(265, 106, 80, -1));
jPanel1.add(jdbTextField7, new XYConstraints(343, 103, 118, 24));
jPanel1.add(jLabel9, new XYConstraints(265, 139, 64, -1));
jPanel1.add(jdbTextField9, new XYConstraints(342, 135, 121, -1));
jPanel1.add(jLabel4, new XYConstraints(36, 43, 51, 22));
jPanel1.add(jLabel10, new XYConstraints(36, 168, 56, 23));
jPanel1.add(jLabel8, new XYConstraints(36, 139, 51, 23));
jPanel1.add(jLabel6, new XYConstraints(36, 104, 56, 20));
jPanel1.add(jLabel5, new XYConstraints(36, 76, 47, 22));
jPanel1.add(jLabel1, new XYConstraints(36, 16, 58, 19));
jPanel1.add(jdbTextField8, new XYConstraints(109, 135, 128, -1));
jPanel1.add(jdbTextField10, new XYConstraints(106, 170, 133, -1));
jPanel1.add(jdbTextField11, new XYConstraints(340, 167, 125, -1));
jPanel1.add(jLabel11, new XYConstraints(267, 168, 53, 23));
jPanel1.add(jdbNavToolBar1, new XYConstraints(1, 202, 526, 40));
this.getContentPane().add(jdbTable1, BorderLayout.CENTER);
}
}
===========================
上面得代码是我学习Java得时候使用JB7得时候使用Nortwind中文数据库得代码!可能不能运行,应为DataBase1没有实例话!你可以生成这个对象运行!
|
table吧
|
有啊!
JTable 啊!
不过有狠多的东西都要你自己写的,不能拖过来设置几下就象得非那样好用,
呵呵,
标题,数据,。。。。。。。。。
都可以自己写的,
比得非更灵活,我个人觉得!
呵呵!
JTable 啊!
不过有狠多的东西都要你自己写的,不能拖过来设置几下就象得非那样好用,
呵呵,
标题,数据,。。。。。。。。。
都可以自己写的,
比得非更灵活,我个人觉得!
呵呵!
|
Database + QueryDataSet
TableScrollPane + JdbTable + JdbNavToolBar
找一本介绍jbuilder的书,上面都有介绍数据库应用的
TableScrollPane + JdbTable + JdbNavToolBar
找一本介绍jbuilder的书,上面都有介绍数据库应用的
|
namowen(寒号不已) 说的是标准的用法符合楼主的简单易用的需求.