title: Strange syntax for instantiating an inner class
body: <p>I didn't imagine that I would encounter radically new syntax in Java anymore at this stage, but lo and behold, I just encountered something:</p>
  
  <p><em>The exact context and what the code below should do is pretty irrelevant - it's there just to give some kind of context.</em></p>
  
  <p>I'm trying to synthetically create an event in IT Mill Toolkit, so I wrote this kind of line:</p>
  
  <pre><code>buttonClick(new Button.ClickEvent(button));
  </code></pre>
  
  <p>But, Eclipse gives me the following error message:</p>
  
  <blockquote>
    <p>No enclosing instance of type Button is accessible. Must qualify the allocation with an enclosing instance of type Button (e.g. x.new A() where x is an instance of Button).</p>
  </blockquote>
  
  <p>When I rewrite the line above as follows, it doesn't complain anymore:</p>
  
  <pre><code>buttonClick(button.new ClickEvent(button)); // button instanceof Button
  </code></pre>
  
  <p>So, my question is: <strong>What does the latter syntax mean, exactly, and why doesn't the first snippet work?</strong> What is Java complaining about, and what's it doing in the second version?</p>
  
  <p><em>Background info: Both <code>Button</code> and <code>Button.ClickEvent</code> are non-abstract public classes.</em></p>