title: Two ways of using JOptionPane classes from Swing
body: <p>Experimenting with Swing, I learnt that there are two ways of using JOptionPane and other classes from Swing:</p>
  
  <p>1) Declare </p>
  
  <pre><code>private JOptionPane info1 = new JOptionPane();
  </code></pre>
  
  <p>before the class constructor and then use <code>info1.showMessageDialog()</code> in the relevant method (in this case I get message that <code>showMessageDialog</code> should be accessed in a static way) , or</p>
  
  <p>2) In the relevant method use </p>
  
  <pre><code>JOptionPane.showMessageDialog()
  </code></pre>
  
  <p>without declaring the object of JOPtionPane class at all. </p>
  
  <p>My question is, what are the differences, drawbacks and benefits of these two approaches? Does it extend to other Swing classes?  </p>