社区
Web 开发
帖子详情
JOptionPane.showMessageDialog(null,"");
hippoppower
2008-05-31 11:06:03
用 JOptionPane.showMessageDialog(null,"");弹一个对话框,当程序运行到弹出对话框的时候,浏览器一直在"正在打开网页",对话框不弹,怎么回事?
...全文
322
7
打赏
收藏
JOptionPane.showMessageDialog(null,"");
用 JOptionPane.showMessageDialog(null,"");弹一个对话框,当程序运行到弹出对话框的时候,浏览器一直在"正在打开网页",对话框不弹,怎么回事?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
我V信_ynsz120
2009-04-28
打赏
举报
回复
不错
hippoppower
2008-06-01
打赏
举报
回复
原来是弹出来之后 自动躲到了浏览器的后面 怎么设能自动置前啊?
erydemimi
2008-06-01
打赏
举报
回复
[Quote=引用 4 楼 bao110908 的回复:]
不知道楼主想要做什么?为什么要弹出个对话框呢?
[/Quote]
hippoppower
2008-06-01
打赏
举报
回复
谢谢 很有收获 我想验证重复注册的问题 用代码搞了半天 总有问题 就取巧的想到了直接用java弹出个对话框 没有想到这个对话框根本不是浏览器的 呵呵 非常感谢
[Quote=引用 3 楼 bao110908 的回复:]
代码在那里阻塞了啊,所以一直显示是打开网页。
这个不是让它置不置前的问题,在 B/S 程序中就不应该使用 C/S 的组件。
B/S 程序是在浏览器/服务器式模型,之所以会弹出对话框来,是由于你的客户机端浏览器和
服务器是同一台机器。如果用两台机器的话,客户端浏览器在请求页面时也会在服务器端跳出
个对话框,在客户端的机器上并不会跳出来,客户端浏览器则一直处于“正在打开网页”状态,
因为服务端的对话框没有…
[/Quote]
火龙果被占用了
2008-06-01
打赏
举报
回复
不知道楼主想要做什么?为什么要弹出个对话框呢?
火龙果被占用了
2008-06-01
打赏
举报
回复
代码在那里阻塞了啊,所以一直显示是打开网页。
这个不是让它置不置前的问题,在 B/S 程序中就不应该使用 C/S 的组件。
B/S 程序是在浏览器/服务器式模型,之所以会弹出对话框来,是由于你的客户机端浏览器和
服务器是同一台机器。如果用两台机器的话,客户端浏览器在请求页面时也会在服务器端跳出
个对话框,在客户端的机器上并不会跳出来,客户端浏览器则一直处于“正在打开网页”状态,
因为服务端的对话框没有人去输入东西。一直处于阻塞状态。
所以说 B/S 程序不应该使用 C/S 的组件,应该采用 HTML 页面或者 JavaScript 来进行对
话框的设计。
jdlsfl
2008-05-31
打赏
举报
回复
可能是使用的场合不对
java项目之餐饮管理系统
java项目package project.action.
dialog
Action; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.
JOptionPane
; import project.dao.common.DbException; import project.dao.dataDao.LoginInfoDao; import project.dao.dataDaoImpl.LoginInfoDaoImpl; import project.view.
dialog
.AddLoginInfo
Dialog
; import project.vo.LoginInfoVo; /** * 添加登录账号action * * @author Administrator * */ public class AddLoginInfoAction implements ActionListener { private AddLoginInfo
Dialog
dialog
; public AddLoginInfoAction(AddLoginInfo
Dialog
dialog
) { this.
dialog
=
dialog
; } public void actionPerformed(ActionEvent e) { String name = e.getActionCommand(); if (name.equals("确定")) { // 检验输入是否正确 if (
dialog
.checkInputValue()) { LoginInfoDao dao =
null
; LoginInfoVo vo =
null
; try { // 获得界面输入信息 vo =
dialog
.getInputInfo(); String confirm =
dialog
.getConfirm(); if (vo.getLog_pwd().equals(confirm)) { dao = new LoginInfoDaoImpl(); if (dao.insertLoginInfo(vo)) { // 打印提示信息
JOptionPane
.show
Message
Dialog
(
null
, "添加登录人员成功", "提示信息",
JOptionPane
.YES_OPTION);
dialog
.dispose(); } else { // 打印提示信息
JOptionPane
.show
Message
Dialog
(
null
, "添加登录人员失败", "提示信息",
JOptionPane
.YES_OPTION); } } else { // 如果密码确认输入错误,打印提示信息
JOptionPane
.show
Message
Dialog
(
null
, "密码确认错误,请重新输入", "提示信息",
JOptionPane
.YES_OPTION); } } catch (DbException ex) {
JOptionPane
.show
Message
Dialog
(
null
, ex.get
Message
(), "提示信息",
JOptionPane
.YES_OPTION); } } else {
JOptionPane
.show
Message
Dialog
(
null
, "请确认输入是否完整正确", "提示信息",
JOptionPane
.YES_OPTION); } } else if (name.equals("取消")) {
dialog
.dispose(); } } }
学生信息系统
public void freshTable(String sql){ myConnection conn=new myConnection(); ResultSet rs; rs=conn.getResult(sql); if (rs!=
null
){ try{ mm.setRowCount(0); table.setModel(mm); while(rs.next()){ String 学号 = rs.getString("学号"); String 姓名 = rs.getString("姓名"); String 性别 = rs.getString("性别"); String 民族 = rs.getString("民族"); String 年龄 = rs.getString("年龄"); String 年级 = rs.getString("年级"); String 班级 = rs.getString("班级"); String 专业 = rs.getString("专业"); String[] cloumns ={学号,姓名,性别,民族,年龄,年级,班级,专业}; mm.addRow(cloumns); } //table.clearSelection(); table.setModel(mm); }catch(Exception e){ System.out.println(e.toString()); } } } public void actionPerformed(ActionEvent e){ //退出 if (e.getSource()==miExit){ System.exit(0); //查找 }else if(e.getSource()==miFind){ findFrame ff=new findFrame(this); ff.setVisible(true); //添加 }else if(e.getSource()==miAdd){ addFrame af=new addFrame(this); af.setVisible(true); //修改 }else if(e.getSource()==miEdit){ if (table.getSelectedRow()==-1){
JOptionPane
.show
Message
Dialog
(
null
, "请选择你要修改的内容", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ editFrame ef=new editFrame(this); ef.学号.setText((String)table.getValueAt(table.getSelectedRow(),0)); ef.姓名.setText((String)table.getValueAt(table.getSelectedRow(),1)); ef.性别.setText((String)table.getValueAt(table.getSelectedRow(),2)); ef.民族.setText((String)table.getValueAt(table.getSelectedRow(),3)); ef.年龄.setText((String)table.getValueAt(table.getSelectedRow(),4)); ef.年级.setText((String)table.getValueAt(table.getSelectedRow(),5)); ef.班级.setText((String)table.getValueAt(table.getSelectedRow(),6)); ef.专业.setText((String)table.getValueAt(table.getSelectedRow(),7)); ef.setVisible(true); this.freshTable("select * from 学生信息表"); } //删除 }else if(e.getSource()==miDel){ if (table.getSelectedRow()==-1){
JOptionPane
.show
Message
Dialog
(
null
, "请选择你要删除的行", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else { String sql="delete from 学生信息表 where 学号 = '"+table.getValueAt(table.getSelectedRow(),0)+"'"; //
JOptionPane
.show
Message
Dialog
(
null
, sql, "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); myConnection conn=new myConnection(); if (conn.executeSql(sql)){
JOptionPane
.show
Message
Dialog
(
null
, "成功删除", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); this.freshTable("select * from 学生信息表"); }else {
JOptionPane
.show
Message
Dialog
(
null
, "未知错误", "删除失败",
JOptionPane
.INFORMATION_
MESSAGE
); } } //显示 }else if(e.getSource()==miShow){ //
JOptionPane
.show
Message
Dialog
(
null
, "未知错误", "删除失败",
JOptionPane
.INFORMATION_
MESSAGE
); this.freshTable("select * from 学生信息表"); //用户管理 }else if(e.getSource()==miUser){ userFrame uf=new userFrame(); uf.setVisible(true); //关于 }else if(e.getSource()==miAbout){ aboutFrame af=new aboutFrame(); af.setVisible(true); } } } class myConnection{ ResultSet re; String strurl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=学生管理数据库.mdb"; public myConnection(){} public ResultSet getResult(String sql){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(strurl); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet re=stmt.executeQuery(sql); return re; } catch(Exception e){ System.out.println("getResult------"+e.toString()); return
null
; } } public boolean executeSql(String sql){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(strurl); Statement stmt=conn.createStatement(); stmt.executeUpdate(sql); conn.commit(); return true; } catch(Exception e){ System.out.println("executeSql----"+e.toString()); return false; } } } class addFrame extends J
Dialog
implements ActionListener{ public static final int WIDTH = 400; public static final int HEIGHT = 400; JLabel 学号1,姓名1,性别1,民族1,年龄1,年级1,班级1,专业1; JTextField 学号,姓名,性别,民族,年龄,年级,班级,专业; JButton b; JPanel p; mainFrame mf; public addFrame(mainFrame mmf){ setTitle("修改学生信息"); setSize(WIDTH,HEIGHT); setLocation(120,180); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); 学号1=new JLabel("学号"); 姓名1=new JLabel("姓名"); 性别1=new JLabel("性别"); 民族1=new JLabel("民族"); 年龄1=new JLabel("年龄"); 年级1=new JLabel("年级"); 班级1=new JLabel("班级"); 专业1=new JLabel("专业"); 学号=new JTextField(5); 姓名=new JTextField(5); 性别=new JTextField(5); 民族=new JTextField(5); 年龄=new JTextField(5); 年级=new JTextField(5); 班级=new JTextField(10); 专业=new JTextField(10); b=new JButton("确定"); p=new JPanel(); p.setLayout(new GridLayout(10,2,5,5)); p.add(学号1); p.add(学号); p.add(姓名1); p.add(姓名); p.add(性别1); p.add(性别); p.add(民族1); p.add(民族); p.add(年龄1); p.add(年龄); p.add(年级1); p.add(年级); p.add(班级1); p.add(班级); p.add(专业1); p.add(专业); p.add(new Label("")); p.add(new Label("")); p.add(b); contentPane.add(p); //添加按钮监听器 b.addActionListener(this); mf=mmf; } public void actionPerformed(ActionEvent e){ if (学号.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入学号", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (姓名.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入姓名", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (年龄.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入年龄", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ String sql="select * from 学生信息表 where 学号='" + 学号.getText() + "'"; myConnection conn=new myConnection(); ResultSet rs; rs=conn.getResult(sql); try{ //System.out.println(rs.getRow()); if (rs.next()){
JOptionPane
.show
Message
Dialog
(
null
, "此学号已经存在", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ sql="insert into 学生信息表 values('" +学号.getText()+"','"+ 姓名.getText() +"','"+ 性别.getText() +"','"+ 民族.getText() +"',"+ 年龄.getText() +",'"+ 年级.getText() +"','"+ 班级.getText() +"','"+ 专业.getText() +"')"; if (conn.executeSql(sql)){
JOptionPane
.show
Message
Dialog
(
null
, "添加成功", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); mf.freshTable("select * from 学生信息表"); 学号.setText(""); 姓名.setText(""); 性别.setText(""); 民族.setText(""); 年龄.setText(""); 年级.setText(""); 班级.setText(""); 专业.setText(""); }else{
JOptionPane
.show
Message
Dialog
(
null
, "添加失败", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); } } }catch(Exception er){ System.out.println(er.toString()); } } } } class editFrame extends J
Dialog
implements ActionListener{ public static final int WIDTH = 400; public static final int HEIGHT = 400; JLabel 学号1,姓名1,性别1,民族1,年龄1,年级1,班级1,专业1; JTextField 学号,姓名,性别,民族,年龄,年级,班级,专业; JButton b; JPanel p; mainFrame mf; public editFrame(mainFrame mmf){ setTitle("修改学生信息"); setSize(WIDTH,HEIGHT); setLocation(120,180); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); 学号1=new JLabel("学号"); 姓名1=new JLabel("姓名"); 性别1=new JLabel("性别"); 民族1=new JLabel("民族"); 年龄1=new JLabel("年龄"); 年级1=new JLabel("年级"); 班级1=new JLabel("班级"); 专业1=new JLabel("专业"); 学号=new JTextField(5); 姓名=new JTextField(5); 性别=new JTextField(5); 民族=new JTextField(5); 年龄=new JTextField(5); 年级=new JTextField(5); 班级=new JTextField(10); 专业=new JTextField(10); 学号.setEnabled(false); b=new JButton("确定"); p=new JPanel(); p.setLayout(new GridLayout(10,2,5,5)); p.add(学号1); p.add(学号); p.add(姓名1); p.add(姓名); p.add(性别1); p.add(性别); p.add(民族1); p.add(民族); p.add(年龄1); p.add(年龄); p.add(年级1); p.add(年级); p.add(班级1); p.add(班级); p.add(专业1); p.add(专业); p.add(new Label("")); p.add(new Label("")); p.add(b); contentPane.add(p); //添加按钮监听器 b.addActionListener(this); mf=mmf; } public void actionPerformed(ActionEvent e){ if (学号.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入学号", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (姓名.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入姓名", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (年龄.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入年龄", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ String sql="update 学生信息表 set 姓名='"+姓名.getText()+"',性别='"+性别.getText()+"',年龄="+年龄.getText()+",年级='"+年级.getText()+"',班级='"+班级.getText()+"',专业='"+专业.getText()+"',民族='"+民族.getText()+"' where 学号='" + 学号.getText() + "'"; myConnection conn=new myConnection(); try{ //
JOptionPane
.show
Message
Dialog
(
null
, sql, "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); if (conn.executeSql(sql)){
JOptionPane
.show
Message
Dialog
(
null
, "修改成功", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); mf.freshTable("select * from 学生信息表"); this.dispose(); }else{
JOptionPane
.show
Message
Dialog
(
null
, "修改失败", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); } }catch(Exception er){ System.out.println(er.toString()); } } } } class findFrame extends J
Dialog
implements ActionListener{ mainFrame mf; JPanel p; JComboBox c; JTextField t; JButton b; JButton fAll; String sql="select * from student"; String[] colStr={"学号","姓名","性别","民族","年龄","年级","班级","专业"}; public findFrame(mainFrame mmf){ mf=mmf; p=new JPanel(); c=new JComboBox(colStr); t=new JTextField(10); b=new JButton("查找"); fAll=new JButton("全部显示"); b.addActionListener(this); fAll.addActionListener(this); p.add(new JLabel("选择")); p.add(c); p.add(new JLabel("查找内容")); p.add(t); p.add(b); p.add(fAll); this.add(p); this.setTitle("查找"); this.setSize(450,80); } public void actionPerformed(ActionEvent e){ //查找 if (e.getSource()==b){ String selectStr=c.getSelectedItem().toString(); if (selectStr=="年龄"){ sql="select * from 学生信息表 where "+selectStr+" = "+t.getText().toString(); } else { sql="select * from 学生信息表 where "+selectStr+" = '"+t.getText().toString()+"'"; } mf.freshTable(sql); //全部显示 }if (e.getSource()==fAll){ sql="select * from 学生信息表"; mf.freshTable(sql); } } } class aboutFrame extends J
Dialog
{ aboutFrame(){ JPanel p1=new JPanel(); p1.add(new JLabel("学生信息管理系统")); p1.add(new JLabel("版权所有:农福刚")); p1.add(new JLabel("农福刚有限责任公司出口")); p1.add(new JLabel("QQ:14159391")); p1.setLayout(new GridLayout(4,1,5,5)); this.add(p1); this.setTitle("关于我"); this.setSize(300,200); } } class userFrame extends JFrame implements ActionListener{ JTextField user,pass; JButton add,del; JTable t; JPanel p1,p2,p3,p4,p5; DefaultTableModel m; public userFrame(){ p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); user=new JTextField(8); pass=new JTextField(8); add=new JButton("添加"); del=new JButton("删除"); String[] col = {"用户名","密码"}; m= new DefaultTableModel(col,0); t=new JTable(); t.setModel(m); JScrollPane sp = new JScrollPane(t); p1.add(new JLabel("用户名")); p1.add(user); p1.add(new JLabel("密码")); p1.add(pass); p1.add(add); p2.add(sp); p3.add(del); add.addActionListener(this); del.addActionListener(this); myConnection conn=new myConnection(); ResultSet rs; rs=conn.getResult("select * from 管理员"); if (rs!=
null
){ try{ //m.setRowCount(0); //table.setModel(mm); while(rs.next()){ String 用户名 = rs.getString("用户名"); String 密码 = rs.getString("密码"); String[] cloumns ={用户名,密码}; m.addRow(cloumns); } t.setModel(m); }catch(Exception e){ System.out.println(e.toString()); } } this.add(p1,BorderLayout.NORTH); this.add(p2,BorderLayout.CENTER); this.add(p3,BorderLayout.SOUTH); this.add(p4,BorderLayout.WEST); this.add(p5,BorderLayout.EAST); this.setTitle("用户管理"); this.setSize(600,400); } public void actionPerformed(ActionEvent e){ //添加 if (e.getSource()==add){ if (user.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入用户名", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (pass.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入密码", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ myConnection conn=new myConnection(); ResultSet rs; try{ rs=conn.getResult("select * from 管理员 where 用户名='"+user.getText().toString()+"'"); if (rs.next()){
JOptionPane
.show
Message
Dialog
(
null
, "此用户已经存在", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ if (conn.executeSql("insert into 管理员 values('"+user.getText().toString()+"','"+pass.getText().toString()+"')")){ String[] newUser={user.getText(),pass.getText()}; m.addRow(newUser); t.setModel(m);
JOptionPane
.show
Message
Dialog
(
null
, "添加成功", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{
JOptionPane
.show
Message
Dialog
(
null
, "添加失败", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); } } }catch(Exception er){ System.out.println(er.toString()); } } //删除 }else if (e.getSource()==del){ if (t.getSelectedRow()==-1){
JOptionPane
.show
Message
Dialog
(
null
, "请选择你要删除的行", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else { String sql="delete from 管理员 where 用户名 = '"+t.getValueAt(t.getSelectedRow(),0)+"'"; //
JOptionPane
.show
Message
Dialog
(
null
, sql, "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); myConnection conn=new myConnection(); if (conn.executeSql(sql)){ m.removeRow(t.getSelectedRow()); t.setModel(m); //t.removeRowSelectionInterval();
JOptionPane
.show
Message
Dialog
(
null
, "成功删除", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else {
JOptionPane
.show
Message
Dialog
(
null
, "未知错误", "删除失败",
JOptionPane
.INFORMATION_
MESSAGE
); } } } } } class loginFrame extends J
Dialog
implements ActionListener{ JPanel p; JTextField user,pass; JButton login,cancel; public loginFrame(){ p=new JPanel(); user=new JTextField(10); pass=new JTextField(10); login=new JButton("登录"); cancel=new JButton("退出"); user.setText("admin"); pass.setText("admin"); login.addActionListener(this); cancel.addActionListener(this); p.add(new JLabel("账号")); p.add(user); p.add(new JLabel("密码")); p.add(pass); p.add(login); p.add(cancel); this.add(p); this.setTitle("系统登录"); this.setSize(180,130); } public void actionPerformed(ActionEvent e){ //查找 if (e.getSource()==login){ if (user.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入用户名", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else if (pass.getText().toString().equals("")){
JOptionPane
.show
Message
Dialog
(
null
, "请输入密码", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); }else{ myConnection conn=new myConnection(); ResultSet rs; String sql="select * from 管理员 where 用户名 = '"+user.getText().toString()+"' and 密码 = '"+pass.getText().toString()+"'"; try{ rs=conn.getResult(sql); if (rs.next()){ this.dispose(); //
JOptionPane
.show
Message
Dialog
(
null
, "此用户已经存在", "温馨提示",
JOptionPane
.INFORMATION_
MESSAGE
); sql="select * from 学生信息表"; mainFrame mf=new mainFrame(); mf.setTitle("农福刚学生信息管理系统"); mf.setSize(600,486); mf.freshTable(sql); mf.setVisible(true); mf.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); }else{
JOptionPane
.show
Message
Dialog
(
null
, "用户名或密码错误", "登录失败",
JOptionPane
.INFORMATION_
MESSAGE
); } }catch(Exception er){ System.out.println(er.toString()); } } //全部显示 }if (e.getSource()==cancel){ System.exit(0); } } }
jdbc for sqlserver2000.rar
//连接数据库的方法 public static Connection geconnection() { //这里可以设置数据库名称 final String URL = "jdbc:sqlserver://localhost:1433;DatabaseName=master"; final String USER="sa"; final String PASSWORD=""; Connection con =
null
; try { //1.加载驱动程序 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //2.获得数据库的连接 con=DriverManager.getConnection(URL,USER,PASSWORD);
JOptionPane
.show
Message
Dialog
(
null
,"数据库连接成功!"); } catch (SQLException e) {
JOptionPane
.show
Message
Dialog
(
null
,e.get
Message
()); } catch (ClassNotFoundException e) {
JOptionPane
.show
Message
Dialog
(
null
,"请检查sqlserver2000驱动"); e.printStackTrace(); } return con; }
java假期练习程序.rar
import javax.swing.
JOptionPane
; public class Product{ public static void main(String args[]) {String firstNumber; String secondNumber; int number1=0; int number2=0; int product; firstNumber=
JOptionPane
.showInput
Dialog
("输入乘数"); secondNumber=
JOptionPane
.showInput
Dialog
("shurubeichengshu"); try{ number1=Integer.parseInt(firstNumber); number2=Integer.parseInt(secondNumber); } catch(NumberFormatException ex){
JOptionPane
.show
Message
Dialog
(
null
,"aaaaaaaaaaaaaaaa","xiaoxi",
JOptionPane
.PLAIN_
MESSAGE
); System.exit(0); } product=number1*number2;
JOptionPane
.show
Message
Dialog
(
null
,number1+"*"+number2+"="+product,"jieguo",
JOptionPane
.PLAIN_
MESSAGE
); System.exit(0); } }
企业固定资产管理系统
package contorl; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.ResultSet; import java.sql.SQLException; import javax.swing.
JOptionPane
; import model.DBManager; import view.DelUserPane; public class DUControl implements ActionListener { private DelUserPane du; private DBManager db=new DBManager(); private ResultSet rs; int eid=0; /** * @param pane */ public DUControl(DelUserPane pane) { du=pane; // TODO 自动生成构造函数存根 } /* (非 Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { // TODO 自动生成方法存根 Object btn=e.getSource(); String uid=du.numbertex.getText().trim(); String sql="select * from users where uid="; if(uid.equals("")) {
JOptionPane
.show
Message
Dialog
(
null
,"请输入用户编号"); return; } if(btn==du.findbtn) { eid=Integer.parseInt(uid); du.delbtn.setEnabled(true); du.cancelbtn.setEnabled(true); dofine(sql); return; } if(btn==du.cancelbtn) { du.nametex.setText(""); du.nametex.setText("" + ""); du.deptex.setText(""); du.notetex.setText(""); return; } if(btn==du.delbtn) { boolean success=false; String name=du.nametex.getText().trim(); String dep=du.deptex.getText().trim(); String note=du.notetex.getText().trim(); if(name.equals("")||dep.equals("")) {
JOptionPane
.show
Message
Dialog
(
null
,"请把信息填完整"); return; } int confirm=
JOptionPane
.showConfirm
Dialog
(
null
,"是否删除?","删除确认",
JOptionPane
.YES_NO_OPTION); if(confirm==
JOptionPane
.YES_OPTION) { sql="update users set udel=0 where uid="+eid; System.out.println(sql); success=db.executeSql(sql); if(!success) {
JOptionPane
.show
Message
Dialog
(
null
,"删除不成功,请重试"); du.delbtn.setEnabled(false); du.cancelbtn.setEnabled(false); return; } else {
JOptionPane
.show
Message
Dialog
(
null
,"删除成功"); du.nametex.setText(""); du.numbertex.setText(""); du.deptex.setText(""); du.notetex.setText(""); du.delbtn.setEnabled(false); du.cancelbtn.setEnabled(false); return; } } } // TODO 自动生成方法存根 } private void dofine(String sql) { sql=sql+eid; rs=db.getResult(sql); try { if(!rs.first()|(rs.getInt(5)==0)) {
JOptionPane
.show
Message
Dialog
(
null
,"没有该用户或者已经被删除"); du.delbtn.setEnabled(false); du.numbertex.setText(""); du.cancelbtn.setEnabled(false); return; } else { rs.beforeFirst(); while(rs.next()) { du.nametex.setText(rs.getString(2)); du.deptex.setText(rs.getString(3)); du.notetex.setText(rs.getString(4)); } } }catch(SQLException sqle) {
JOptionPane
.show
Message
Dialog
(
null
,"没有该用户或者已经被删除"); System.out.println(sqle); du.numbertex.setText(""); du.delbtn.setEnabled(false); du.cancelbtn.setEnabled(false); return; } } }
Web 开发
81,092
社区成员
341,717
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章