免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1552 | 回复: 0
打印 上一主题 下一主题

applet luncher文件怎么没看见 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-25 03:51 |只看该作者 |倒序浏览
通常用  applet 产生的文件在folder builder下。但我以下的程序怎么没有生成。

  1. import javax.swing.*;
  2. import java.sql.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.sql.Timestamp;


  6. public class dbJava extends JApplet implements ActionListener{
  7.     public String login;
  8.     public String pwd;
  9.     private boolean isStandalone=false;
  10.     private JTextField jtfuser=new JTextField(5);
  11.     private JTextField jtfpwd =new JTextField(5);
  12.   
  13.     private JPanel jpanel1;
  14.     private JButton jbtLogin=new JButton("Login");
  15.     public Statement state, db2state;
  16.   //  private medicalform newMf;
  17.     public static JFrame frame;
  18.    
  19.     /** Creates a new instance of dbJava */
  20.     public dbJava() {
  21.       
  22.     }
  23.    
  24.     //initialize applet
  25.     public void init(){
  26.         
  27.    
  28.       initialize();
  29.       jtfpwd=new JTextField(5);
  30.   //    jtfpwd.setEchoChar('*');     
  31.         
  32.         jpanel1=new JPanel();
  33.         jpanel1.add(new JLabel("User name"));
  34.         jpanel1.add(jtfuser);
  35.         jpanel1.add(new JLabel("Password"));
  36.         jpanel1.add(jtfpwd);
  37.         jpanel1.add(jbtLogin);
  38.         
  39.         getContentPane().setLayout(new FlowLayout());
  40.         getContentPane().add(jpanel1, BorderLayout.NORTH);
  41.       
  42.         jbtLogin.addActionListener(this);
  43.      
  44.          
  45.         
  46.     }
  47.     private void initialize(){
  48.       
  49.         try{
  50.          
  51.             //load jbc driver
  52.             Class.forName("com.mysql.jdbc.Driver");
  53.             System.out.println("Driver Loaded");
  54.             
  55.             //Establish connection
  56.             Connection connection=DriverManager.getConnection("jdbc:mysql://localhost/books","root","000405");
  57.             
  58.             System.out.println("Database connected");
  59.             //create statement
  60.             state=connection.createStatement();
  61.             
  62.         }
  63.         catch(Exception ex){
  64.             ex.printStackTrace();
  65.         }
  66.         
  67.     }
  68.    
  69.     public void actionPerformed(ActionEvent e){
  70.       
  71.     login=jtfuser.getText();
  72.     pwd=jtfpwd.getText();
  73.     try{
  74.         String query="select firstName, lastName from authors " + "where firstName = '" +  login +"' and lastName = '"+pwd +"' ";   
  75.         
  76.         ResultSet rset=state.executeQuery(query);
  77.         if(rset.next()){
  78.             String user=rset.getString(1);
  79.             String pswd=rset.getString(2);
  80.             jpanel1.removeAll();
  81.             
  82.             initialzeSecondDB();
  83.             
  84.         }else
  85.             //Display if user not found
  86.                JOptionPane.showMessageDialog(null, "User not found");
  87.     }
  88.     catch(SQLException ex){
  89.         ex.printStackTrace();
  90.     }
  91. }
  92.     void initialzeSecondDB(){
  93.          try{
  94.               close();
  95.              medicalform newMf=new medicalform();
  96.          
  97.         }
  98.         catch(Exception ex){
  99.             ex.printStackTrace();
  100.         }
  101.         
  102.     }
  103.     public void close(){
  104.         
  105.         frame.setVisible(false);
  106.         
  107.     }
  108.    
  109.      public void init2(){
  110.         
  111.         
  112.         initialize();
  113.       
  114.         jtfpwd=new JTextField(5);
  115.        // jtfpwd.setEchoChar('*');     
  116.         
  117.         jpanel1=new JPanel();
  118.         jpanel1.add(new JLabel("User name"));
  119.         jpanel1.add(jtfuser);
  120.         jpanel1.add(new JLabel("Password"));
  121.         jpanel1.add(jtfpwd);
  122.         jpanel1.add(jbtLogin);
  123.         
  124.         jbtLogin.addActionListener(this);
  125.      //   this.getContentPane().add(jpanel1, BorderLayout.NORTH);
  126.          
  127.          frame=new JFrame();
  128.         dbJava applet=new dbJava();
  129.       
  130.         applet.isStandalone=true;
  131.         
  132.      //   frame.getContentPane().add(applet, BorderLayout.NORTH);
  133.         
  134.         applet.init();
  135.       //  applet.start();
  136.       
  137.       
  138.    
  139.           frame.setTitle("Medical Database");
  140.           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  141.           frame.setSize(400,100);
  142.           frame.setVisible(true);
  143.          
  144.     }
  145.     public static void main(String args[]){
  146.         //create frame
  147.          frame=new JFrame();
  148.         dbJava applet=new dbJava();
  149.       
  150.         applet.isStandalone=true;
  151.         
  152.         frame.getContentPane().add(applet, BorderLayout.EAST);
  153.         
  154.         applet.init();
  155.      //   applet.start();
  156.       
  157.         
  158.           frame.setTitle("Medical Database");
  159.           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  160.           frame.setSize(400,100);
  161.           frame.setVisible(true);
  162.          
  163.         
  164.     }
  165. }

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP