Re: [問題] 寫視窗程式執行的問題
※ 引述《qrtt1 (null)》之銘言:
: ※ 引述《Horre (我不認識你 就這樣!)》之銘言:
: : 之前 有發文問資料庫的問題,
: : 所提到的登入視窗是用JCreator編寫的
: : 不過編譯後的class檔,用dos模式下執行java指令會產生錯誤
: : http://aa40101.myweb.hinet.net/Error.JPG
: : 找了好幾次都找不到bug= ="
: 這不是 bug。是你對 compiler 有誤解。
: 把你的 source code (含 main 的那隻) 簡化後貼上來。
: 還有你執行路徑與 .class 的關係也描述一下。
package pack1;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
//import java.net.*;
public class login extends JFrame implements ActionListener
{
static login F1 = new login();
static JTextField t1 = new JTextField(10);
static JPasswordField t2 = new JPasswordField(10);
static JButton b1 = new JButton("登入");
static JButton b2 = new JButton("重填");
public static void main(String args[])
{
Container CP = F1.getContentPane();
GridLayout grid=new GridLayout(1,1);
CP.setLayout(grid);
JPanel p3 = new JPanel();
b1.addActionListener(F1);
b2.addActionListener(F1);
p3.add(b1);
p3.add(b2);
//.........
CP.add(p3);
F1.setBounds(400,300,250,150);
F1.setTitle("管理者登入");
F1.setVisible(true);
F1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}//public static void main
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
try
{
String id = t1.getText();
String pd = new String(t2.getPassword());
connect con = new connect();
String sql="select * from admin where Id='"+ id+"' and
passwd='"+pd+"'";
ResultSet rs=con.doQuery(sql);
if(rs.next())
{
String name = rs.getString(4);
JOptionPane.showMessageDialog(null,name+"\n歡迎登入管理系統!","
訊息",JOptionPane.WARNING_MESSAGE);
}else{
JOptionPane.showMessageDialog(null,"帳號或密碼錯誤!","錯誤
",JOptionPane.WARNING_MESSAGE);
}
con.doClose();
}//try
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"帳號或密碼錯誤!","錯誤
",JOptionPane.WARNING_MESSAGE);
System.err.println(ex);
}
} //if(e.getSource()==bu1)
}//public void actionPerformed
}//public class longin
____________________________________________________
執行路徑是指path的設定路徑??
--
Let me beside you,
That's enough.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.107.188.113
推
01/04 11:38, , 1F
01/04 11:38, 1F
討論串 (同標題文章)