Netbeans对编译表示怀疑

如何解决Netbeans对编译表示怀疑

| 我有一个在netbeans中创建的项目,在编译时创建了很好的类文件。但是,如果在编译后有一个名为operator.java的文件,我得到了operator.class,operator $ 1.class,operator $ 2.class等。.这样做有什么特殊的原因吗?您能解释一下为什么会这样吗?
package admin;  
import forms_helper.global_variables;  
import java.sql.ResultSet;  
import java.sql.SQLException;  
import java.util.ArrayList;  
import java.util.List;  
import java.util.logging.Level;  
import java.util.logging.Logger;  
import utilities.mysql_query;  
import utilities.variables;  
public class stock_adjust extends javax.swing.JFrame {`  

    List<String> list = new ArrayList<String>();
    List<String> list_id = new ArrayList<String>();
    List<String> list_quantity = new ArrayList<String>();

    /** Creates new form stock_adjust */
    public stock_adjust() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings(\"unchecked\")
    // <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        products = new javax.swing.JList();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel2 = new javax.swing.JLabel();
        product_name = new javax.swing.JTextField();
        qty = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        cancel = new javax.swing.JButton();
        save = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(\"Stock Adjust\");
        setLocationByPlatform(true);
        setResizable(false);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel1.setText(\"Search:\");

        jTextField1.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField1CaretUpdate(evt);
            }
        });

        products.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                productsMouseClicked(evt);
            }
        });
        products.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                productsValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(products);

        jLayeredPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Adjust\"));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText(\"Product Name:\");
        jLabel2.setBounds(10,30,80,20);
        jLayeredPane1.add(jLabel2,javax.swing.JLayeredPane.DEFAULT_LAYER);
        product_name.setBounds(100,240,-1);
        jLayeredPane1.add(product_name,javax.swing.JLayeredPane.DEFAULT_LAYER);
        qty.setBounds(100,60,110,-1);
        jLayeredPane1.add(qty,javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText(\"Quantity:\");
        jLabel4.setBounds(10,20);
        jLayeredPane1.add(jLabel4,javax.swing.JLayeredPane.DEFAULT_LAYER);

        cancel.setText(\"Cancel\");
        cancel.setBounds(220,-1,30);
        jLayeredPane1.add(cancel,javax.swing.JLayeredPane.DEFAULT_LAYER);

        save.setText(\"Save\");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });
        save.setBounds(50,73,30);
        jLayeredPane1.add(save,javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton3.setText(\"Keyboard\");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING,layout.createSequentialGroup()
                        .addComponent(jLabel1,javax.swing.GroupLayout.PREFERRED_SIZE,51,javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1,212,javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)
                        .addComponent(jButton3,99,javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING,layout.createSequentialGroup()
                        .addGap(16,16,16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLayeredPane1,356,Short.MAX_VALUE)
                            .addComponent(jScrollPane1,javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18,18,18))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24,24,24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1,javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1,23,Short.MAX_VALUE)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1,210,javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18,18)
                .addComponent(jLayeredPane1,169,javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19,19,19))
        );

        pack();
    }// </editor-fold>                        

    private void jTextField1CaretUpdate(javax.swing.event.CaretEvent evt) {                                        
        try {
            String sql = \"SELECT * FROM pos_products WHERE \"
                    + \"company_id=\'\" + global_variables.company_id + \"\' AND \"
                    + \"shop_type=\'\" + global_variables.shop_type + \"\' AND \"
                    + \"product_name LIKE \'%\" + jTextField1.getText() + \"%\' OR \"
                    + \"barcode LIKE \'%\" + jTextField1.getText() + \"%\'\";

            list.removeAll(list);
            list_id.removeAll(list_id);
            list_quantity.removeAll(list_quantity);
            ResultSet rs = mysql_query.execute_mysql(variables.con.conn,sql);
            products.removeAll();
            while (rs.next()) {
                list.add(rs.getString(\"product_name\"));
                list_id.add(rs.getString(\"p_id\"));
                list_quantity.add(rs.getString(\"available_stock\"));
            }
            products.setListData(list.toArray(new String[list.size()]));
        } catch (SQLException ex) {
            Logger.getLogger(stock_adjust.class.getName()).log(Level.SEVERE,null,ex);
        }
    }                                       

    private void productsValueChanged(javax.swing.event.ListSelectionEvent evt) {                                      
    }                                     

    private void productsMouseClicked(java.awt.event.MouseEvent evt) {                                      
        product_name.setText(list.get(products.getSelectedIndex()));
        qty.setText(list_quantity.get(products.getSelectedIndex()));
    }                                     

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {                                     
        String sql = \"UPDATE pos_products SET \"
                + \"available_stock=\'\" + qty.getText() + \"\' WHERE \"
                + \"company_id=\'\" + global_variables.company_id + \"\' AND \"
                + \"p_id=\'\" + list_id.get(products.getSelectedIndex()) + \"\'\";
        mysql_query.update_mysql(variables.con.conn,sql);
    }                                    

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new stock_adjust().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton cancel;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField product_name;
    private javax.swing.JList products;
    private javax.swing.JTextField qty;
    private javax.swing.JButton save;  }`
在上面的代码中,我得到了6个这样的类。因此,您选择了负责制作该plz的行。oz我在此代码中未使用任何内部类。我不确定Enum概念,所以如果您能帮助我,我可以从那里开始学习。     

解决方法

这不是特定于netbeans的。 附加的类文件是在
operator.java
中声明的匿名类的字节码,或者如果
operator
是声明了按实例方法定义的枚举,则这些文件也由编译器通过这些附加的分类类来实现。 编辑: 这是一个匿名的类定义:
new javax.swing.event.CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent evt) {
            jTextField1CaretUpdate(evt);
        }
    }
您的代码中有几个(MoustListener,ActionListener等)-像这样内联声明侦听器实现是一种常见的习惯。     ,如果您的操作员类中包含内部类或枚举,则在编译后,您将看到类似这样的额外类文件。 更新: 您已经为侦听器使用了匿名类,并且它们都被创建为名称Operator $ 1.calss,..所以您会看到这么多的类文件,因为您正在为侦听器使用匿名类。
.......
products.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                productsMouseClicked(evt);
            }
        });
products.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                productsValueChanged(evt);
            }
        });
.......
    ,
operator.java
必须在内部具有内部类。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-