| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1875 人关注过本帖
标题:[求助]请教 JFrame 和JInternalFrame 有什么区别
取消只看楼主 加入收藏
oucai
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-7-16
收藏
 问题点数:0 回复次数:4 
[求助]请教 JFrame 和JInternalFrame 有什么区别

JFrame 和JInternalFrame 有什么区别?????????
还有我的这段代码为么总是监听出错?????????
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:jsj01";
Connection conn = DriverManager.getConnection(url);
Statement stat = conn.createStatement();
String sql="select * from stu where xuhao='"+jTextField1.getText()+"' ";
ResultSet rSet = stat.executeQuery(sql);
boolean more= rSet.next();
int j=1;
while (more)
{
j++;
more=rSet.next();
}
j--;
Object[][] data=new Object[j][12];
Object[] Colname={"姓名","性别","出生日期","民族","籍贯","学历","毕业学校","住址","入学层次","专业","通知书编号","身份证号"};

ResultSet rSet2 = stat.executeQuery(sql);
rSet2.next();
for(int i=0;i<j;i++)
{
data[i][0] =rSet2.getString(1);
data[i][1] =rSet2.getString(2);
data[i][2] =rSet2.getString(3);
data[i][3] =rSet2.getString(4);
data[i][4] =rSet2.getString(5);
data[i][5] =rSet2.getString(6);
data[i][6] =rSet2.getString(7);
data[i][7] =rSet2.getString(8);
data[i][8] =rSet2.getString(11);
data[i][9] =rSet2.getString(12);
data[i][10] =rSet2.getString(16);
data[i][11] =rSet2.getString(15);
rSet2.next();
}
table = new JTable(data,Colname);
table.setDoubleBuffered(true);
table.setColumnSelectionAllowed(true);
jScrollPane.getViewport().add(table,null);


rSet.close();
}
catch(java.lang.Exception exec)
{
cuowuDialog aboutDialog = new cuowuDialog(this,"guanyu",false);
Dimension dlgSize = new Dimension(350,150);
Dimension frmSize=getSize();
Point loc=getLocation();
aboutDialog.setLocation((frmSize.width -dlgSize.width)/ 2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
aboutDialog.setModal(true);
aboutDialog.setSize(dlgSize);
aboutDialog.jLabel1.setText("对不起,没有此学生信息");
aboutDialog.show();

}

搜索更多相关主题的帖子: JFrame 
2006-07-22 11:25
oucai
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-7-16
收藏
得分:0 
请各位高手给出具体的意见,谢谢

在变成黄土的前一刻,都会想着JAVA问题如何去解决
2006-07-22 11:27
oucai
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-7-16
收藏
得分:0 

哦,晓得了
那上面的代码那出错了


在变成黄土的前一刻,都会想着JAVA问题如何去解决
2006-07-22 14:16
oucai
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-7-16
收藏
得分:0 

package luanqiangxian;

import javax.swing.*;
import com.borland.jb.util.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import com.borland.jbcl.layout.*;
import javax.swing.event.*;
import com.borland.dbswing.*;


public class chaxunFrame extends JInternalFrame {
static int frameNo=1;
static final int xOffset=50,yOffset=50;

public chaxunFrame() {
super("查询考生信息"+(frameNo++),true,true,true,true);
setSize(800,1024);
setLocation(xOffset*frameNo,yOffset*frameNo);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jPanel1.setLayout(xYLayout1);
jTextField1.setFont(new java.awt.Font("Dialog", 0, 16));
jTextField1.setText("");
jTextField1.addMouseListener(new chaxunFrame_jTextField1_mouseAdapter(this));
jTextField2.setText("");
jTextField2.setFont(new java.awt.Font("Dialog", 0, 16));
jTextField3.setText("");
jTextField3.setFont(new java.awt.Font("Dialog", 0, 16));
jButton1.setFont(new java.awt.Font("Dialog", 0, 14));
jButton1.setText("按通知书编号查询");
jButton1.addActionListener(new chaxunFrame_jButton1_actionAdapter(this));
table.setFont(new java.awt.Font("Dialog", 0, 20));
jScrollPane.setFont(new java.awt.Font("Dialog", 0, 20));
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jScrollPane, new XYConstraints(29, 149, 978, 382));
jPanel1.add(jTextField1, new XYConstraints(28, 30, 163, 24));
jPanel1.add(jTextField2, new XYConstraints(28, 56, 163, 24));
jPanel1.add(jTextField3, new XYConstraints(28, 81, 163, 24));
jPanel1.add(jButton1, new XYConstraints(202, 29, 148, 24));
jScrollPane.getViewport().add(table, null);
}
JPanel jPanel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JScrollPane jScrollPane = new JScrollPane();
JTable table = new JTable();
JButton jButton1 = new JButton();
void jButton1_actionPerformed(ActionEvent e) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:jsj01";
Connection conn = DriverManager.getConnection(url);
Statement stat = conn.createStatement();
String sql="select * from stu where xuhao='"+jTextField1.getText()+"' ";
ResultSet rSet = stat.executeQuery(sql);
boolean more= rSet.next();
int j=1;
while (more)
{
j++;
more=rSet.next();
}
j--;
Object[][] data=new Object[j][12];
Object[] Colname={"姓名","性别","出生日期","民族","籍贯","学历","毕业学校","住址","入学层次","专业","通知书编号","身份证号"};

ResultSet rSet2 = stat.executeQuery(sql);
rSet2.next();
for(int i=0;i<j;i++)
{
data[i][0] =rSet2.getString(1);
data[i][1] =rSet2.getString(2);
data[i][2] =rSet2.getString(3);
data[i][3] =rSet2.getString(4);
data[i][4] =rSet2.getString(5);
data[i][5] =rSet2.getString(6);
data[i][6] =rSet2.getString(7);
data[i][7] =rSet2.getString(8);
data[i][8] =rSet2.getString(11);
data[i][9] =rSet2.getString(12);
data[i][10] =rSet2.getString(16);
data[i][11] =rSet2.getString(15);
rSet2.next();
}
table = new JTable(data,Colname);
table.setDoubleBuffered(true);
table.setColumnSelectionAllowed(true);
jScrollPane.getViewport().add(table,null);


rSet.close();
}
catch(java.lang.Exception exec)
{
cuowuDialog aboutDialog = new cuowuDialog(this,"guanyu",false);
Dimension dlgSize = new Dimension(350,150);
Dimension frmSize=getSize();
Point loc=getLocation();
aboutDialog.setLocation((frmSize.width -dlgSize.width)/ 2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
aboutDialog.setModal(true);
aboutDialog.setSize(dlgSize);
aboutDialog.jLabel1.setText("对不起,没有此学生信息");
aboutDialog.show();

}

}

void jTextField1_mousePressed(MouseEvent e) {
jTextField2.setText("");
jTextField3.setText("");
}

class chaxunFrame_jButton1_actionAdapter implements java.awt.event.ActionListener {
chaxunFrame adaptee;

chaxunFrame_jButton1_actionAdapter(chaxunFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}

class chaxunFrame_jTextField1_mouseAdapter extends java.awt.event.MouseAdapter {
chaxunFrame adaptee;

chaxunFrame_jTextField1_mouseAdapter(chaxunFrame adaptee) {
this.adaptee = adaptee;
}
public void mousePressed(MouseEvent e) {
adaptee.jTextField1_mousePressed(e);
}
}

小弟写的实在是太菜,你门就凑合着看看吧,有什么好的意见就尽管提啊!谢谢


在变成黄土的前一刻,都会想着JAVA问题如何去解决
2006-07-22 14:38
oucai
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-7-16
收藏
得分:0 
结果能运行出来,但是总是执行总是出现"对不起,没有此学生信息"

在变成黄土的前一刻,都会想着JAVA问题如何去解决
2006-07-22 14:51
快速回复:[求助]请教 JFrame 和JInternalFrame 有什么区别
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031399 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved