你把最后一行代码“javax.swing.JOptionPane.showMessageDialog(null,"str");”
改为javax.swing.JOptionPane.showMessageDialog(null,str);就可以了