zoukankan      html  css  js  c++  java
  • No enclosing instance of type E is accessible.

    No enclosing instance of type E  is accessible.

    静态方法(main)中调用内部类,会出现这样的问题;

    学习了:https://www.cnblogs.com/runnigwolf/p/5570810.html

    http://blog.csdn.net/sunny2038/article/details/6926079

    public class SwingObserverExample {
        public static void main(String[] args) {
            JFrame jFrame = new JFrame();
            JButton jButton = new JButton("Should I do it?");
            jButton.addActionListener(new SwingObserverExample().new  AngelListener());
            jButton.addActionListener(new DevilListener());
            jFrame.getContentPane().add(jButton);
            jFrame.setVisible(true);
        }
        class AngelListener implements ActionListener{
    
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("Don't do it!");
            }
            
        }
        static class DevilListener implements ActionListener{
    
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("Just do it!");
            }
            
        }
        
    }
  • 相关阅读:
    git中文输入显示问题
    how to write a DLL/SO in C/C++ for Python
    python,ctypes
    vc++,dll,lib文件百科
    c++ singleton
    build python on windows
    web前端后端
    动态链接库*.so的编译与使用
    qt,ui,QUiLoader
    qt,script
  • 原文地址:https://www.cnblogs.com/stono/p/7868387.html
Copyright © 2011-2022 走看看