ÀûÓÃJava SwingÉè¼Æ±ê×¼¶Ô»°¿ò
SwingÖÐÌṩÁËJOptionPaneÀàÀ´ÊµÏÖÀàËÆWindowsƽ̨ϵÄMessageBoxµÄ¹¦ÄÜ£¬Í¬ÑùÔÚJavaÖÐÒ²ÓУ¬ÀûÓÃJOptionPaneÀàÖеĸ÷¸östatic·½·¨À´Éú³É¸÷ÖÖ±ê×¼µÄ¶Ô»°¿ò£¬ÊµÏÖÏÔʾ³öÐÅÏ¢¡¢Ìá³öÎÊÌâ¡¢¾¯¸æ¡¢Óû§ÊäÈë²ÎÊýµÈ¹¦ÄÜ¡£ÕâЩ¶Ô»°¿ò¶¼ÊÇģʽ¶Ô»°¿ò¡£
¡¡¡¡ConfirmDialog¡¡---¡¡È·È϶Ի°¿ò£¬Ìá³öÎÊÌ⣬ȻºóÓÉÓû§×Ô¼ºÀ´È·ÈÏ£¨°´"Yes"»ò"No"°´Å¥£©
¡¡¡¡InputDialog¡¡---¡¡ÌáʾÊäÈëÎı¾
¡¡¡¡MessageDialog¡¡---¡¡ÏÔʾÐÅÏ¢
¡¡¡¡OptionDialog¡¡-£¡¡×éºÏÆäËüÈý¸ö¶Ô»°¿òÀàÐÍ¡£
¡¡¡¡ÕâËĸö¶Ô»°¿ò¿ÉÒÔ²ÉÓÃshowXXXDialog()À´ÏÔʾ£¬ÈçshowConfirmDialog()ÏÔʾȷÈ϶Ի°¿ò¡¢showInputDialog()ÏÔʾÊäÈëÎı¾¶Ô»°¿ò¡¢showMessageDialog()ÏÔʾÐÅÏ¢¶Ô»°¿ò¡¢showOptionDialog()ÏÔʾѡÔñÐԵĶԻ°¿ò¡£ËüÃÇËùʹÓõIJÎÊý˵Ã÷ÈçÏ£º
¡¡¡¡¢Ù ParentComponent£ºÖ¸Ê¾¶Ô»°¿òµÄ¸¸´°¿Ú¶ÔÏó£¬Ò»°ãΪµ±Ç°´°¿Ú¡£Ò²¿ÉÒÔΪnull¼´²ÉÓÃȱʡµÄFrame×÷Ϊ¸¸´°¿Ú£¬´Ëʱ¶Ô»°¿ò½«ÉèÖÃÔÚÆÁÄ»µÄÕýÖС£
¡¡¡¡¢Ú message£ºÖ¸Ê¾ÒªÔÚ¶Ô»°¿òÄÚÏÔʾµÄÃèÊöÐÔµÄÎÄ×Ö
¡¡¡¡¢Û String title£º±êÌâÌõÎÄ×Ö´®¡£
¡¡¡¡¢Ü Component£ºÔÚ¶Ô»°¿òÄÚÒªÏÔʾµÄ×é¼þ£¨Èç°´Å¥£©
¡¡¡¡¢Ý Icon£ºÔÚ¶Ô»°¿òÄÚÒªÏÔʾµÄͼ±ê
¡¡¡¡¢Þ messageType£ºÒ»°ã¿ÉÒÔΪÈçϵÄÖµERROR_MESSAGE¡¢INFORMATION_MESSAGE¡¢WARNING_MESSAGE¡¢QUESTION_MESSAGE¡¢PLAIN_MESSAGE¡¢
¡¡¡¡¢ß optionType£ºËü¾ö¶¨ÔÚ¶Ô»°¿òµÄµ×²¿ËùÒªÏÔʾµÄ°´Å¥Ñ¡Ïî¡£Ò»°ã¿ÉÒÔΪDEFAULT_OPTION¡¢YES_NO_OPTION¡¢YES_NO_CANCEL_OPTION¡¢OK_CANCEL_OPTION¡£
¡¡¡¡Ê¹ÓÃʵÀý£º
¡¡¡¡(1) ÏÔʾMessageDialog
JOptionPane.showMessageDialog(null, "ÔÚ¶Ô»°¿òÄÚÏÔʾµÄÃèÊöÐÔµÄÎÄ×Ö", "±êÌâÌõÎÄ×Ö´®", JOptionPane.ERROR_MESSAGE);
(2) ÏÔʾConfirmDialog
JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
setLabel("OK. Keep an eye on your wallet.");
} else if (n == JOptionPane.NO_OPTION) {
setLabel("Whew! Good choice.");
} else {
setLabel("It is your civic duty to cast your vote.");
}
(3) ÏÔʾOptionDialog£º¸ÃÖÖ¶Ô»°¿ò¿ÉÒÔÓÉÓû§×Ô¼ºÀ´ÉèÖø÷¸ö°´Å¥µÄ¸öÊý²¢·µ»ØÓû§µã»÷¸÷¸ö°´Å¥µÄÐòºÅ£¨´Ó0¿ªÊ¼¼ÆÊý£©
Ïà¹ØÎĵµ£º
JavaÏß³ÌÊÇJavaÓïÑÔÖÐÒ»¸ö·Ç³£ÖØÒªµÄ²¿·Ö£¬Java5֮ǰ£¬¶àÏ̵߳ÄÓïÑÔÖ§³Ö»¹ÊDZȽÏÈõµÄ£¬ÄÚÈÝÒ²½ÏÉÙ£¬Ð´Ò»¸ö¸´ÔӵĶàÏ̳߳ÌÐòÊÇÏ൱ÓÐÌôÕ½ÐԵġ£
ÔÚJava5ÒÔºó£¬Java¶Ô¶àÏß³Ì×öÁ˺ܶàÀ©Õ¹£¬À©Õ¹²¿·Ö³Æ֮Ϊ²¢·¢°ü¡£Õⲿ·ÖÄÚÈÝ´ó´óÔöÇ¿ÁËJava¶àÏ̱߳à³ÌµÄÄÜÁ¦£¬Í¨¹ýʹÓÃJava5Ïß³ÌÐÂÌØÕ÷µÄAPI£¬¿ÉÒÔºÜÈÝÒ×µÄ×ö³ö¸´Ô ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:Verdana;
panose ......
Ò»¡¢Ï̸߳ÅÊö
Ïß³ÌÊdzÌÐòÔËÐеĻù±¾Ö´Ðе¥Ôª¡£µ±²Ù×÷ϵͳ(²»°üÀ¨µ¥Ï̵߳IJÙ×÷ϵͳ£¬Èç΢ÈíÔçÆÚµÄDOS)ÔÚÖ´ÐÐÒ»¸ö³ÌÐòʱ£¬»áÔÚϵͳÖн¨Á¢Ò»¸ö½ø³Ì£¬¶øÔÚÕâ¸ö½ø³ÌÖУ¬±ØÐëÖÁÉÙ½¨Á¢Ò»¸öỊ̈߳¨Õâ¸öÏ̱߳»³ÆΪÖ÷Ị̈߳©À´×÷ΪÕâ¸ö³ÌÐòÔËÐеÄÈë¿Úµã¡£Òò´Ë£¬ÔÚ²Ù×÷ϵͳÖÐÔËÐеÄÈκγÌÐò¶¼ÖÁÉÙÓÐÒ»¸öÖ÷Ï̡߳£
½ø³ÌºÍÏß³ÌÊÇÏÖ´ú²Ù× ......
JavaÖÐͨ¹ýimplements SerializableÀ´ÊµÏÖ¶ÔÏóµÄÐòÁл¯¡£ÆäʵSerializable½Ó¿ÚÖв¢Ã»ÓÐÐèҪʵÏֵķ½·¨£¬×¢Ã÷ij¸öÀàimplements SerializableÖ»ÊÇΪÁ˱êʶ»ò±íÃ÷Õâ¸öÀà¿ÉÒÔ±»ÐòÁл¯¡£
ÄÇôʲôÊÇÐòÁл¯ÄØ£¬ÐòÁл¯ÓÖÓÐʲô×÷ÓÃÄØ£¿
Ò»¸öÀ࣬»ò ......
ava IOѧϰ±Ê¼Ç£º¸ÅÄîÓëÔÀí
Ò»¡¢¸ÅÄî
JavaÖжÔÎļþµÄ²Ù×÷ÊÇÒÔÁ÷µÄ·½Ê½½øÐеġ£Á÷ÊÇJavaÄÚ´æÖеÄÒ»×éÓÐÐòÊý¾ÝÐòÁС£Java½«Êý¾Ý´ÓÔ´£¨Îļþ¡¢ÄÚ´æ¡¢¼üÅÌ¡¢ÍøÂ磩¶ÁÈëµ½ÄÚ´æÖУ¬ÐγÉÁËÁ÷£¬È»ºó½«ÕâЩÁ÷»¹¿ÉÒÔдµ½ÁíÍâµÄÄ¿µÄµØ£¨Îļþ¡¢ÄÚ´æ¡¢¿ØÖÆ̨¡¢ÍøÂ磩£¬Ö®ËùÒÔ³ÆΪÁ÷£¬ÊÇÒòΪÕâ¸öÊý¾ÝÐòÁÐÔÚ²»Í¬Ê±¿ÌËù²Ù ......