Java SwingÖеÄJTreeÄ£ÐÍ
±¾ÎĽéÉÜJava SwingÖеÄJTreeÄ£ÐÍ£¬½éÉÜÈçºÎ´´½¨¡¢Ð޸ġ¢±éÀú£¬ÉèÖÃÊ÷¡£²Î¿¼Core Java2Ïà¹ØÕ½ڼ°ÆäÔ´´úÂë¡£
SwingÊ÷ʹÓÃÈËÃÇËùÊìϤµÄÎļþ¼ÐºÍÊ÷ҶͼÀ´ÏÔʾ·Ö²ãµÄÊý¾Ý¡£Ê÷Óɽڵã×é³É£¬½Úµã¿ÉÒÔÊÇÎļþ¼Ð£¬Ò²¿ÉÒÔÊÇÊ÷Ò¶¡£Îļþ¼Ð¿ÉÒÔÓÐ×ӽڵ㣬³ý¸ù½ÚµãÖ®ÍâµÄËùÓнڵ㶼ֻÓÐÒ»¸ö¸¸½Úµã¡£¿ÕµÄÎļþ¼ÐÓëÊ÷Ò¶µÄ²»Í¬Ö®´¦¾ÍÔÚÓÚËüÔÊÐíÓÐ×ӽڵ㡣
³ý¸¸½ÚµãºÍ×Ó½ÚµãÍ⣬Ê÷µÄ½Úµã»¹ÓÐÒ»¸öÓû§¶ÔÏó(µ±Ê¹ÓÃDefaultTreeModelʱ¾Í»á³ÊÏÖÒ»¸öÓû§¶ÔÏó)¡£Óû§¶ÔÏóÊÇObjectÀàÐÍ£¬Òò´ËËüÌṩÁËÒ»¸ö½«ÈÎÒâ¶ÔÏóÓë½ÚµãÏà¹ØÁªµÄ°ì·¨¡£
Ê÷ÓÐÒ»¸ö¼òµ¥µÄÄ£ÐÍ£¬Ã¿Ò»¸öJTreeʵÀý¶¼ÒªÎ¬»¤¶Ô»æÖÆÆ÷ºÍ±à¼Æ÷µÄÒýÓã¬Õâ¸ö»æÖÆÆ÷ºÍ±à¼Æ÷±»Ê÷ÖÐËùÓеĽڵãËùʹÓᣱí1ÖÐÁгöÁËswing.tree°üÖеÄÖ÷ÒªÀà¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡±í1 Swing.tree°üÖеÄÖ÷ÒªÀà
¡¡Ãû¡¡³Æ ʵ¡¡ÏÖ
DefaultMutableTreeNode Ò»¸ö¾ßÓÐÒ»¸ö¸¸½Úµã¡¢£¨¿ÉÄÜ£©Ðí¶à×Ó½ÚµãºÍ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ò»¸öÓû§¶ÔÏóµÄ¿É±ä½Úµã£¬ÎªÏà¹ØÁªµÄ½ÚµãÌṩÁË·ÃÎÊ·½·¨¡£Èç¹ûûÓÐÈκÎ×ӽڵ㣬Õâ¸ö½Úµã¾ÍÊÇÊ÷Ò¶¡£
DefaultTreeModel Ò»¸ö¼¤·¢TreeModel EventsʼþµÄ¼òµ¥¿É±äµÄÄ£ÐÍ¡£Ìṩ¶Ô×Ó½ÚµãµÄ·ÃÎÊ·½·¨£¬µ«²»ÊÇÌṩ¶Ô¸¸½ÚµãµÄ·ÃÎÊ·½·¨¡£
DefaultTreeCellEditor »æÖÆÆ÷ºÍ±à¼Æ÷µÄ°ü×°Æ÷£¬Ëü°ÑÒ»¸ö“ÕæÕý”µÄ±à¼Æ÷×é¼þ·ÅÔÚ½Úµãͼ±êµÄÅԱߡ£
DefaultTreeCellRenderer ¾ßÓÐ×ÖÌå¡¢ÑÕÉ«ºÍͼ±ê·ÃÎÊ·½·¨µÄJLabelÀ©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Õ¹£¬ËüÌṩͼ±êµÄȱʡֵ¡£
TreePath ÓÉÒ»¸ö½Úµãµ½ÁíÒ»¸ö½ÚµãµÄ·¾¶¡£Â·¾¶ÖеĽڵã´æ´¢ÔÚÒ»¸öÊý×éÖС£Â·¾¶ÓÃÓÚÔÚÑ¡È¡ÄÚÈÝÖ®¼ä½øÐÐͨÐÅ¡£
1£®¹¹½¨Ê÷Ä£ÐÍ
Ïêϸ´úÂë¼ûSimpleTree.java
DefaultMutableTreeNode root = new DefaultMutableTreeNode("World");
DefaultMutableTreeNode country = new DefaultMutableTreeNode("USA");
root.add(country);
¡£¡£¡£
JTree tree = new JTree(root);
Container contentPane = getContentPane();
contentPane.add(new JScrollPane(tree));
ÕâЩ´úÂëÀ´×ÔÒ»¸öJFrameµÄ¹¹Ôì×ÓÖС£ÕâÀïͨ¹ýJTreeÀ´´´½¨Ò»¸öTreeModelµÄʵÀý¡£
2£®Ê÷½áµã
Ê÷½ÚµãÓÉTreeNode½Ó¿Ú¶¨Ò壬TreeNode½Ó¿Ú±»MutableTreeNode½Ó¿ÚÀ©Õ¹£¬¶øMutableTreeNode½Ó¿ÚÓÖÓÉ DefaultMutableTreeNodeÀàÀ´ÊµÏÖ¡£
Ê÷½á¹¹ÏêϸÀàͼ
2.1 TreeNode½Ó¿Ú
TreeNode½Ó¿Ú¶¨ÒåÁË£¨¹Ì¶¨£©Ê÷½ÚµãµÄʵÖÊ£¬±í2×ܽáÁËTreeNodeÏà¹Ø·½·¨¡£
±í2TreeNode½Ó¿Ú
public abstract Enu
Ïà¹ØÎĵµ£º
ÔÚÎÒÃÇд³ÌÐòµÄʱºò,ÓÐʱ»áÒªÇó±£´æһЩÊý¾Ý,±ÈÈçÓû§Ãû»òÕß±ðµÄ,µ«ÊÇÕâÑùÊý¾ÝÓÖ²»ÊDZ£´æÔÚ³ÌÐòͬһĿ¼ÏÂ,ÕâÑù×öÌ«Ã÷ÏÔÁË,Ò²²»Ì«°²È«,ÄÇÔõô°ìÄØ?Õâ¸öʱºò,Èç¹ûÄÜ°ÑÊý¾Ý±£´æµ½×¢²á±íÀïÃæÈ¥,ÄǸöàºÃ,Ò»À´Òþ±Î,¶þÀ´·½±ã,²»ÖÁÓÚÔÚ³ÌÐòĿ¼ÏÂÉú³ÉÒ»´óƬÎļþ.
ÔÚJAVAÀïÃæ,¿ÉÒÔÀûÓÃjava.util.prefs.PreferencesÀ´¶Ô×¢²á±í½øÐ ......
Java ½Ó¿ÚºÍ³éÏóÀàÇø±ð ÊÕ²Ø
À´Ô´ http://blog.csdn.net/sunboard/archive/2009/01/18/3831823.aspx
Ò»¸öÈí¼þÉè¼ÆµÄºÃ»µ£¬ÎÒÏëºÜ´ó³Ì¶ÈÉÏÈ¡¾öÓÚËüµÄÕûÌå¼Ü¹¹£¬¶øÕâ¸öÕûÌå¼Ü¹¹Æäʵ¾ÍÊÇÄã¶ÔÕû¸öºê¹ÛÉÌÒµÒµÎñµÄ³éÏó¿ò¼Ü£¬µ±´ú±íÒµÎñÂß¼µÄ¸ß²ã³éÏó²ã½á¹¹ ºÏÀíʱ£¬Äãµ×²ãµÄ¾ßÌåʵÏÖÐèÒª¿¼Âǵľͽö½öÊÇһЩËã·¨ºÍһЩ¾ßÌåµÄÒµ ......
Java ½Å±¾ API ¸ÅÊö
½Å±¾ÒýÇæ
½Å±¾ÒýÇæ¾ÍÊÇÖ¸½Å±¾µÄÔËÐл·¾³£¬ËüÄÜÄܹ»°ÑÔËÐÐÆäÉϵĽâÊÍÐÔÓïÑÔת»»Îª¸üµ×²ãµÄ»ã±àÓïÑÔ£¬Ã»Óнű¾ÒýÇ棬½Å±¾¾ÍÎÞ·¨±»ÔËÐС£
Java SE 6 ÒýÈëÁË¶Ô Java Specification Request£¨JSR£©223 µÄÖ§³Ö£¬JSR 223 Ö¼ÔÚ¶¨ÒåÒ»¸öͳһµÄ¹æ·¶£¬Ê¹µÃ Java Ó¦ÓóÌÐò¿ÉÒÔͨ¹ýÒ»Ì׹̶¨µÄ½Ó¿ÚÓë¸÷Öֽű ......
ÔÚ»ùÓÚ Java
ÓïÑԵıà³ÌÖУ¬ÎÒÃǾ³£Åöµ½ºº×ֵĴ¦Àí¼°ÏÔʾµÄÎÊÌâ¡£Ò»´ó¶Ñ¿´²»¶®µÄÂÒÂë¿Ï¶¨²»ÊÇÎÒÃÇÔ¸Òâ¿´µ½µÄÏÔʾЧ¹û£¬ÔõÑù²ÅÄܹ»ÈÃÄÇЩºº×ÖÕýÈ·ÏÔʾÄØ£¿JavaÓïÑÔ
ĬÈϵıàÂ뷽ʽÊÇUNICODE£¬¶øÎÒÃÇÖйúÈËͨ³£Ê¹ÓõÄÎļþºÍÊý¾Ý¿â¶¼ÊÇ»ùÓÚGB2312»òÕßBIG5µÈ·½Ê½±àÂëµÄ£¬ÔõÑù²ÅÄܹ»Ç¡µ±µØÑ¡Ôñºº×Ö±àÂ뷽ʽ
²¢ÕýÈ·µØ ......
1.ÉùÃ÷°ü£ºpackage °üÃû
¸ÃÓï¾äÊÇ×÷ΪjavaÔ´ÎļþµÄµÚÒ»ÌõÓï¾ä Ö¸Ã÷¸ÃÔ´Îļþ¶¨ÒåµÄÀàËùÔڵİü
2.µ¼°ü£ºimport °üÃû
¸ÃÓï¾ä±ØÐëдÔÚpackageÓï¾äºÍÔ´Îļ ......