ÖÇÄÜÊý¾ÝʹSwing±£³Ö¼òµ¥ - ±à³ÌÈëÃÅÍø
Æ÷ÒÔ²éÕÒ Object ÀàÐ͵ÄÊý¾Ý£¬Õâ¸ö±à¼Æ÷ʵ¼ÊÉÏÊÇ Ò»¸ö String ±à¼Æ÷¡£Ò»µ©Í£Ö¹±à¼£¬¸Ã±à¼Æ÷¾Í·µ»ØÒ»¸ö String Öµ£¬Õâ¸ö String Öµ³Ö ¾Ã´æ´¢ÔÚÄ£ÐÍÖУ¬ÆäÖÐʹÓà String ÖµÌæ»» iData ²ãʵÏÖ¡£ÏÂͼÃè»æÁËÒª±£³Ö iData ¼ä½Ó µÄÍêÕûÐÔ±ØÐë×ñѵıà¼Ë³Ðò¡£
ͼ 5. ±à¼Ë³Ðò ËäÈ»¿ÉÒÔÀ©Õ¹ÒÑÓеıà¼Æ÷À´×ñѸÃ˳Ðò£¬µ«ÕâÖÖ·½·¨ÊDz»ÇÐʵ¼ÊµÄ£»Ëü»áµ¼Ö¹ý¶àµÄÀà ºÍÔì³É²»±ØÒªµÄ¸´ÔÓÐÔ¡£¶¨ÖƱà¼Æ÷ÔÚijЩ¶ÀÌØÇé¿öÏÂÊÇ¿ÉÐеģ¬µ«ÊÇ´ó¶àÊý±à¼Æ÷½«×ñÑ ÏàͬµÄ˳Ðò£¬¿ÉÒÔ½«Õâһ˳Ðò·â×°ÔÚÒ»¸öµ¥¶ÀµÄÀàÖС£iData ¹¤¾ßÏä°üº¬Õâ¸öÀàµÄÒ»¸öʵÏÖ £¬³ÆΪ UniversalTableCellEditor ¡£ UniversalTableCellEditor ʹÓà TableCellEditor µÄÄÚº¶ø²»ÊÇÆäÀ©Õ¹¡£ÔÚ±à¼Ê±£¬ UniversalTableCellEditor ´Ó iData ²ãʵÏÖ³éÈ¡³öÊý¾ÝÖµ£¬²¢Ê¹ÓøÃÖµ³õʼ»¯Ëùº¬µÄ TableCellEditor ¡£µ±Í£Ö¹±à¼Ê±£¬ UniversalTableCellEditor ´Ó TableCellEditor Öмì Ë÷¸ÃÖµ²¢ÏàÓ¦µØÔÚ iData ʵÏÖÖÐÉèÖøÃÖµ¡£Èç¹û¿ªÊ¼Ã»ÓÐÖ¸¶¨±à¼Æ÷£¬Ôò UniversalTableCellEditor ¼ìË÷ JTable ÖеÄȱʡ±à¼Æ÷ÒÔ²éÕÒ iData ʵÏÖµÄÊý¾ÝÀàÐÍ¡£ ÔÚÒÔÉÏËùÊöµÄÕû¸ö±à¼³ÌÐòÍêÈ«·â×°ÔÚ UniversalTableCellEditor ÖС£ÕâÒâζ×Å£¬¿ÉÒÔ Ê¹ÓÃÈκαà¼Æ÷£¬ÉõÖÁÊǵÚÈý·½±à¼Æ÷£¬¶ø²»ÐèҪʵÏÖ iData Âß¼µÄÀ©Õ¹¡£ ÎÒ½¨Òéͨ¹ý½«Ã¿¸ö TableColumn µÄȱʡ±à¼Æ÷ÉèÖÃ³É UniversalTableCellEditor À´Éè Öà JTable Öеıà¼Æ÷¡£iData ¹¤¾ßÏ京ÓÐÒ»¸ö´øÓм¸¸ö¾²Ì¬ÖúÊÖ·½·¨µÄʵÓÃÀࡣʵÓÃÀàÖÐ µÄ configureTable() ·½·¨¶Ô TableColumns ½øÐбéÀú£¬½«Ã¿¸öµ±Ç°±à¼Æ÷ÉèÖóɰüº¬ÄÇÒ» ÁÐÒÔÇ°µÄµ¥Ôª±à¼Æ÷µÄ UniversalTableCellEditor µÄÐÂʵÀý¡£ µ±¹¤¾ßÏäÓëäÖȾÆ÷Ïà¹Øʱ£¬ËüÓоßÓÐÀàËƹ¦ÄÜµÄ UniversalTableCellRenderer £¬Ëü¾ßÓÐ ÓëäÖȾÆ÷ÀàËƵŦÄÜ¡£¹¤¾ßÏäÖл¹°üÀ¨ JTree ºÍ JComboBox/JList µÄͨÓñà¼Æ÷ºÍäÖȾÆ÷ ×éºÏ¡£ ÖÇÄÜÊý¾ÝʹSwing±£³Ö¼òµ¥(9)ʱ¼ä:2011-04-16 IBM Jonathan SimonʾÀý£ºµ¥ÔªÄÚÑéÖ¤±£Ö¤Á˼۸ñ¸ßÓڳɱ¾ ±à¼µÄ±ê×¼À§ÄÑÊÇ µ¥ÔªÄÚÑéÖ¤£¬¼´ÔÚµ¥Ôª±à¼Í£Ö¹Ö®Ç°½øÐÐÊý¾ÝÑéÖ¤¡£ setData() ·½·¨ ´´½¨ÁËÒ»¸öÓÃÓÚµ¥ÔªÄÚÑéÖ¤µÄ¼¯ÖÐλÖá£Ç뿼ÂÇÕâÑùÒ»¸öʾÀý£¬ÔÚ¶Ô price »ò cost ½øÐÐ±à ¼Ö®ºó£¬Èç¹û price ÖµµÍÓÚ cost £¬ÔòÓû§Ó¦¸Ã½Óµ½Í¨Öª¡£Õâʱ£¬ÎÒÃÇÏ£ÍûÏòÓû§ÏÔʾÏÂÁÐ Ñ¡Ï ¶ÔÁ½¸öÖµ²»×öÈκδ¦Àí¡£ Ìá¸ß price ʹ֮µÈÓÚ cost ¡£ ÐÞ¸Äδ±à¼µÄÄǸöÖµ£¬Ê¹Õâ¸öÖµÓë¸Õ±à¼¹ýµÄÖµÖ®¼äµÄ²îÖµÓë×î³õµÄ¼Û²îÏàµÈ¡£ ÔÚ setData() ·½·¨ÖУ¬ÊµÏÖËüÃÇÏà¶Ô±È½ÏÈÝÒס£ËüÏòÓû§ÌṩÁËÒ»¸ö JOptionPane ÒÔ±ê ʶÊ×Ñ¡µÄÑ¡Ïî¡£Ò»µ©Ñ¡¶¨ÁËij¸öÑ¡ÏÔò»áÖ´ÐмÆËãÒÔÉèÖÃÊʵ±µÄÖµ¡£ÖªµÀʵÏÖÕâÒ»ÒµÎñÂß ¼µÄËùÓÐÊý¾ÝÖµÒÔ¼°¼¯ÖÐλÖÃÊÇ iData ¼¼ÊõÁé»îÐԵĹؼü¡£ Çåµ¥ 9. µ¥ÔªÄÚÑéÖ¤
|
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |