|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
°³¿ä: NESTED | Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå |
public interface TreeModel
JTree
¿¡ ÃÖÀûÀÎ µ¥ÀÌÅÍ ¸ðµ¨À» Á¤ÀÇÇÏ´Â ÀÎÅÍÆäÀ̽ºÀÔ´Ï´Ù. Ä¿½ºÅÒ ±¸ÇöÀÇ ¿¹¸¦ Æ÷ÇÔÇÑ Æ®¸® ¸ðµ¨ÀÇ »ó¼¼ÇÑ °Í¿¡ ´ëÇÏ¿©´Â
¡¸The Java Tutorial¡¹ÀÇ¡¸How to Use Trees¡¹¸¦ ÂüÁ¶ÇϽʽÿÀ.
JTree
¿Í ±× °ü·Ã Ŭ·¡½º´Â
TreeModel
³»ÀÇ ³ëµå¸¦ ½Äº°Çϱâ À§Çؼ TreePath
¸¦
±¤¹üÀ§ÇÏ°Ô °ÉÃÄ »ç¿ëÇÕ´Ï´Ù. TreeModel
·Î °°Àº ºÎ¸ð¾Æ·¡ÀÇ 2 °³°¡ ´Ù¸¥ À妽º¿¡ ÀÖ´Â °°Àº ¿ÀºêÁ§Æ® (equals
·Î ºñ±³µÈ °Í)°¡ µ¹·ÁÁÖ°íÁö¸é, »ý¼ºµÈ TreePath
¿ÀºêÁ§Æ®µµ ÀÌ¿Í °°ÀÌ µ¿ÀÏÇÏ´Ù°í º¸¿©Áý´Ï´Ù. ÀϺÎÀÇ ±¸Çö¿¡¼´Â
2 °³ÀÇ TreePath
°¡ µ¿ÀÏÇÑ °æ¿ì, ±×°ÍµéÀº °°Àº ³ëµå¶ó°í º¸¿©Áö´Â ÀÏÀÌ ÀÖ½À´Ï´Ù. ÀÌ Á¶°ÇÀÌ Ã¤¿öÁöÁö ¾ÊÀ¸¸é ÆäÀÎÆ® ¹®Á¦³ª ±× ¿ÜÀÇ ÀÌ»óÇÑ »çŰ¡ ¹ß»ýÇÏ´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù. ¹Ù²Ù¾î ¸»Çϸé, ƯÁ¤ÀÇ ºÎ¸ð¿¡ ´ëÇÑ getChild
·Î °°Àº Object (equals
·Î ÆÇÁ¤µÈ °Í)°¡ µ¹·ÁÁÖ°íÁ³À» °æ¿ì´Â ¹®Á¦°¡ ¹ß»ýÇÏ´Â ÀÏÀÌ Àֱ⠶§¹®¿¡
ÀÌ·¯ÇÑ Ã³¸®´Â ½Ç½ÃÇÏÁö ¾Ê´Â °ÍÀ» ÃßõÇÕ´Ï´Ù.
TreePath
¸Þ¼µå °³¿ä | |
---|---|
void |
addTreeModelListener (TreeModelListener l)
Æ®¸®°¡ º¯°æµÈ µÚ¿¡ ¼Û½ÅµÈ TreeModelEvent
¸®½º³Ê¸¦ Ãß°¡ÇÕ´Ï´Ù. |
Object |
getChild (Object parent,
int index)
ºÎ¸ð°¡ °¡Áö´Â ¾ÆÀÌ ¹è¿ÀÇ, À妽º index ¿¡ ÀÖ´Â parent
¾ÆÀ̸¦ µ¹·ÁÁÝ´Ï´Ù. |
int |
getChildCount (Object parent)
parent
¾ÆÀÌÀÇ ¼ö¸¦ µ¹·ÁÁÝ´Ï´Ù. |
int |
getIndexOfChild (Object parent,
Object child)
ºÎ¸ð¿¡ ÀÖ¾î¼ÀÇ ¾ÆÀÌÀÇ À妽º¸¦ µ¹·ÁÁÝ´Ï´Ù. |
Object |
getRoot ()
Æ®¸®ÀÇ ·çÆ®¸¦ µ¹·ÁÁÝ´Ï´Ù. |
boolean |
isLeaf (Object node)
node °¡ ÀÙÀÇ °æ¿ì´Â true ¸¦
µ¹·ÁÁÝ´Ï´Ù. |
void |
removeTreeModelListener (TreeModelListener l)
±×¶§±îÁö addTreeModelListener ·Î Ãß°¡µÇ°í ÀÖ´ø ¸®½º³Ê¸¦ »èÁ¦ÇÕ´Ï´Ù. |
void |
valueForPathChanged (TreePath path,
Object newValue)
newValue ¿¡ÀÇ path ¿¡
ÇØ ½Äº°µÇ´Â Ç׸ñÀÇ °ªÀ» À¯Àú°¡ º¯°æÇϸé, ¸Þ¼¼Áö·Î ¼Û½ÅµË´Ï´Ù. |
¸Þ¼µåÀÇ »ó¼¼ |
---|
Object getRoot()
null
¸¦
µ¹·ÁÁÝ´Ï´Ù.
Object getChild(Object parent, int index)
index
¿¡ ÀÖ´Â parent
¾ÆÀ̸¦ µ¹·ÁÁÝ´Ï´Ù. parent
´Â
ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ±×¶§±îÁö ÃëµæµÈ ³ëµå°¡ ¾Æ´Ï¸é ¾ÈµË´Ï´Ù. index
°¡ parent
À¯È¿ÇÑ À妽º (Áï,index >= 0 && index < getChildCount(parent
))ÀÎ °æ¿ì´Â
null
¸¦
µ¹·ÁÁÖÁö ¾Ê½À´Ï´Ù.
parent
- ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ÃëµæµÈ, Æ®¸®³»ÀÇ ³ëµå
index
¿¡ ÀÖ´Â parent
¾ÆÀÌint getChildCount(Object parent)
parent
¾ÆÀÌÀÇ ¼ö¸¦ µ¹·ÁÁÝ´Ï´Ù. ³ëµå°¡ ÀÙÀÇ °æ¿ì³ª, ³ëµå°¡ ¾ÆÀ̸¦ °¡ÁöÁö ¾Ê´Â °æ¿ì´Â
0À»
µ¹·ÁÁÝ´Ï´Ù. parent
´Â
ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ±×¶§±îÁö ÃëµæµÈ ³ëµå°¡ ¾Æ´Ï¸é ¾ÈµË´Ï´Ù.
parent
- ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ÃëµæµÈ, Æ®¸®³»ÀÇ ³ëµå
parent
¾ÆÀÌÀÇ ¼öboolean isLeaf(Object node)
node
°¡ ÀÙÀÇ °æ¿ì´Â true
¸¦
µ¹·ÁÁÝ´Ï´Ù. node
°¡ ¾ÆÀ̸¦ °¡ÁöÁö ¾Ê´Â °æ¿ì¿¡¼µµ, ÀÌ ¸Þ¼µå´Â false
¸¦
µ¹·ÁÁÙ ¼ö°¡ ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, ÆÄÀÏ ½Ã½ºÅÛÀÇ µð·ºÅ丮¿¡ ÆÄÀÏÀÌ µé¾î°¡ ÀÖÁö ¾ÊÀº °æ¿ì, ±× µð·ºÅ丮¸¦ ³ªÅ¸³»´Â ³ëµå´Â ÀÙÀÌ ¾Æ´Ò »Ó¸¸ ¾Æ´Ï¶ó, ¾ÆÀ̵µ °¡Áö°í ÀÖÁö ¾Ê½À´Ï´Ù.
node
- ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ÃëµæµÈ, Æ®¸®³»ÀÇ ³ëµå
node
°¡ ÀÙÀÇ °æ¿ì´Â truevoid valueForPathChanged(TreePath path, Object newValue)
newValue
¿¡ÀÇ path
¿¡
ÇØ ½Äº°µÇ´Â Ç׸ñÀÇ °ªÀ» À¯Àú°¡ º¯°æÇϸé, ¸Þ¼¼Áö·Î ¼Û½ÅµË´Ï´Ù. newValue
°¡ Á¤¸»·Î »õ·Î¿î °ªÀ»
¹ÌÇÏ´Â °æ¿ì¿¡´Â
¸ðµ¨Àº treeNodesChanged
À̺¥Æ®¸¦ ¼Û½ÅÇÏÁö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù.
path
- À¯Àú°¡ º¯°æÇÑ ³ëµå¿¡ÀÇ ÆÐ½ºnewValue
- TreeCellEditor ·ÎºÎÅÍÀÇ »õ·Î¿î °ªint getIndexOfChild(Object parent, Object child)
parent
¶Ç´Â child
¾î´À ÂÊÀÎÁö°¡ null
°æ¿ì´Â
-1À»
µ¹·ÁÁÝ´Ï´Ù. parent
¶Ç´Â child
¾î´À ÂÊÀÎÁö°¡ ÀÌ Æ®¸® ¸ðµ¨¿¡ ¼ÓÇÏÁö ¾ÊÀº °æ¿ìµµ,-1¸¦
µ¹·ÁÁÝ´Ï´Ù.
parent
- ÀÌ µ¥ÀÌÅÍ ¼Ò½º·ÎºÎÅÍ ÃëµæµÈ, Æ®¸®³»ÀÇ ³ëµåchild
- ´ë»óÀÌ µÇ´Â ³ëµå
parent
¶Ç´Â child
¾î´À ÂÊÀÎÁö°¡ null
ÀÎÁö, ÀÌ Æ®¸® ¸ðµ¨¿¡ ¼ÓÇÏÁö ¾ÊÀº °æ¿ì´Â -1void addTreeModelListener(TreeModelListener l)
TreeModelEvent
¸®½º³Ê¸¦ Ãß°¡ÇÕ´Ï´Ù.
l
- Ãß°¡ÇÏ´Â ¸®½º³ÊremoveTreeModelListener(javax.swing.event.TreeModelListener)
void removeTreeModelListener(TreeModelListener l)
addTreeModelListener
·Î Ãß°¡µÇ°í ÀÖ´ø ¸®½º³Ê¸¦ »èÁ¦ÇÕ´Ï´Ù.
l
- »èÁ¦ÇÏ´Â ¸®½º³ÊaddTreeModelListener(javax.swing.event.TreeModelListener)
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
°³¿ä: NESTED | Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå |
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.