私有 javax.swing.JTextField3;错误

发布于 2024-08-14 13:52:17 字数 1830 浏览 11 评论 0原文

我非常感谢那些回答我的问题“main方法未找到错误”的人,在更正所有括号后,代码似乎没问题。在IDE上它仍然显示以下错误;

             private javax.swing.JButton jButton1;
             private javax.swing.JComboBox jComboBox1;
             private javax.swing.JLabel jLabel1;
             private javax.swing.JLabel jLabel2;
             private javax.swing.JLabel jLabel3;
             private javax.swing.JLabel jLabel4;
             private javax.swing.JTextField jTextField1;
             private javax.swing.JTextField jTextField2;
error line** private javax.swing.JTextField jTextField3;

即构建失败,指示上面唯一的错误行,因此,这些是 IDE 的变量声明,无法修改。

主要代码是;

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
            preparedStatement ps=conn.prepareStatement("select name,zip,discount_code from customer where customer_id=?");
            ps.setInt(1,Interger.parseInt(jTextField1.getText()));
            ResultSet rs=ps.executeQuery();
            if(rs.next()) { 
                jTextField2.setText(rs.getString(1));
                jTextField3.setText(rs.getString(2));
                jComboBox1.setSelectedItem(rs.getString(3));
    }                                        
        } catch (NumberFormatException ex) {
            ex.PrintStackTrace();
        }catch (SQLException ex){
            ex.printStackTrace();
        }
    }
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new jdfrm().setVisible(true);
                }

I greatly thanks those that reply to my question "main method not found error", after correcting all the parenthesis and it seem the code is alright.On the IDE its still indicate the error below;

             private javax.swing.JButton jButton1;
             private javax.swing.JComboBox jComboBox1;
             private javax.swing.JLabel jLabel1;
             private javax.swing.JLabel jLabel2;
             private javax.swing.JLabel jLabel3;
             private javax.swing.JLabel jLabel4;
             private javax.swing.JTextField jTextField1;
             private javax.swing.JTextField jTextField2;
error line** private javax.swing.JTextField jTextField3;

i.e build failed indicating the only error line above and thus, those are variable declararation by the IDE and it cannot be modify.

The main code is;

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
            preparedStatement ps=conn.prepareStatement("select name,zip,discount_code from customer where customer_id=?");
            ps.setInt(1,Interger.parseInt(jTextField1.getText()));
            ResultSet rs=ps.executeQuery();
            if(rs.next()) { 
                jTextField2.setText(rs.getString(1));
                jTextField3.setText(rs.getString(2));
                jComboBox1.setSelectedItem(rs.getString(3));
    }                                        
        } catch (NumberFormatException ex) {
            ex.PrintStackTrace();
        }catch (SQLException ex){
            ex.printStackTrace();
        }
    }
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new jdfrm().setVisible(true);
                }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长伴 2024-08-21 13:52:17

目前,我能看到的唯一问题是 preparedStatement 应该是 PreparedStatement,是的,用大写的 P 代替。

在 main 方法之后还缺少一个右花括号,但也许 tou 没有复制粘贴所有代码......

Currently, the only problem i can see is that preparedStatement should be PreparedStatement, yes with the capital P, instead.

There is also a closing curly brace missing after the main method, but maybe tou did not copy paste all your code ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文