一般都是都在页面做弹出框,如果后台要做弹出框就可以用JOptionPane类,其中封装了很多的方法。
import javax.swing.JOptionPane;
showMessageDialog
JOptionPane.showMessageDialog(null, "SUCCESS!");
JOptionPane.showMessageDialog(null, "SUCCESS", "TITLE",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "SUCCESS", "TITLE",JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(null, "ERROR" , "TITLE",JOptionPane.ERROR_MESSAGE);
showOptionDialog
int n = JOptionPane.showConfirmDialog(null, "DOWN OR NOT", "TITLE",JOptionPane.YES_NO_OPTION);//Y 0 N 1
Object[] options ={ "OH YES!", "NONO!" };
int m = JOptionPane.showOptionDialog(null, "DOWN OR NOT", "TITLE",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
showInoutDialog
Object[] obj2 ={ "RED", "YELLOW", "GREEN" };
Object[] obj2 ={ "RED", "YELLOW", "GREEN" };
String s = (String) JOptionPane.showInputDialog(null,"WHAT COLOR DO U LIKE?", "COLOR", JOptionPane.PLAIN_MESSAGE, new ImageIcon("icon.png"), obj2, "RED");