title: Set Object's attributes on its creation
body: <p>I sometimes see code like this:</p>
  
  <pre><code>new myJFrame().setVisible(true);
  </code></pre>
  
  <p>I don't exactly know how it works, but it actually creates a <code>myJFrame</code> and sets it visible, as an alternative to setting it visible on its constructor.</p>
  
  <p>What I would like to know is if there would be a way to do this on a JMenuItem or JButton to automatically assign it an ActionListener without having to explicitly declaring it first, as in:</p>
  
  <pre><code>myJMenu.add(new JMenuItem("Item").addActionListener(myActionListener));
  </code></pre>
  
  <p>Which, as far as I've tried, doesn't work.</p>
  
  <p>I don't exactly <em>need</em> it to work, I would just like to know if it is possible, for it would save me some good time.</p>
  
  <p>Thanks in advance.</p>