|
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 µµ ÂüÁ¶ÇϽʽÿÀ.