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