當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultMutableTreeNode.removeFromParent方法代碼示例

本文整理匯總了Java中javax.swing.tree.DefaultMutableTreeNode.removeFromParent方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultMutableTreeNode.removeFromParent方法的具體用法?Java DefaultMutableTreeNode.removeFromParent怎麽用?Java DefaultMutableTreeNode.removeFromParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.removeFromParent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteFriend

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
/**
 * 刪除樹裏麵的某個好友
 */
public void deleteFriend(String groupName,String friendName)
{
	DefaultMutableTreeNode root=(DefaultMutableTreeNode) treeModel.getRoot();
	for(int i=0;i<root.getChildCount();i++)
	{
		if(root.getChildAt(i).toString().startsWith(groupName))
		{
			for(int j=0;j<root.getChildAt(i).getChildCount();j++)
			{
				if(root.getChildAt(i).getChildAt(j).toString().startsWith(friendName))
				{
					System.out.println(root.getChildAt(i).getChildAt(j));
					DefaultMutableTreeNode node=(DefaultMutableTreeNode)root.getChildAt(i).getChildAt(j);
					node.removeFromParent();
					System.out.println("刪除成功!");
				}
				break;
			}
		}
		break;
	}
}
 
開發者ID:sxei,項目名稱:myqq,代碼行數:26,代碼來源:MyTree.java

示例2: deleteFriend

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
/**
 * 刪除好友
 * @param e
 */
public void deleteFriend(ActionEvent e)
{
	DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
	node.removeFromParent();
	JOptionPane.showMessageDialog(null, "刪除好友成功!請關閉並打開當前分組以刷新好友列表!");
}
 
開發者ID:sxei,項目名稱:myqq,代碼行數:11,代碼來源:Main.java

示例3: addSingleMultipleNode

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
@Override
protected DefaultMutableTreeNode addSingleMultipleNode(DefaultMutableTreeNode node, boolean isInnerClass){
	
	// --- Get all needed information about the node, which has to be copied --------
	DynType dt = (DynType) node.getUserObject();
	String clazz = dt.getClassName();
	OntologySingleClassSlotDescription oscsd = dt.getOntologySingleClassSlotDescription();
	
	JPanel oldPanel = dt.getPanel();
	JPanel parentPanel = (JPanel) oldPanel.getParent();

	// --- Get parent node ----------------------------------------------------------
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); 
	int depth2WorkOn = parentNode.getLevel()-1;
	
	// --- Create the panel/node as needed as a copy of the current node ------------
	JPanel blindPanel = new JPanel();
	blindPanel.setLayout(null);
	DefaultMutableTreeNode newNode = null;
	
	if (isInnerClass==true) {
		newNode = this.createInnerElements(oscsd, clazz, depth2WorkOn+1, blindPanel, parentNode, true);
		if (oldPanel.isVisible()==false) {
			// --- Case special class: set invisible and small ------------ 
			this.setJPanelInvisibleAndSmall(newNode);
		}
		
	} else {
		newNode = this.createOuterElements(oscsd, depth2WorkOn, blindPanel, parentNode, true);
	}
	
	// --- Place the node at the right position in the tree -------------------------
	newNode.removeFromParent();
	int nodeIndexPos = parentNode.getIndex(node)+1;
	objectTree.insertNodeInto(newNode, parentNode, nodeIndexPos);
	
	// --- Set the size of the new Panel --------------------------------------------
	DynType dtNew = (DynType) newNode.getUserObject();
	JPanel newPanel = dtNew.getPanel();
	
	// --- Layout the new panel -----------------------------------------------------
	if (oldPanel.isVisible()==true) {
		// ----------------------------------------------------------------
		// --- The normal case for visible classes ------------------------
		// ----------------------------------------------------------------			
		this.setPanelBounds(newPanel);
		newPanel.setPreferredSize(newPanel.getSize());

		// --- Now place the new sub panel on the right super panel -------
		int movement = oldPanel.getHeight() + 2;
		int xPos = oldPanel.getX();
		int yPos = oldPanel.getY() + movement;
		newPanel.setBounds(xPos, yPos, newPanel.getWidth(), newPanel.getHeight());
		
		// --- Add to parent panel ----------------------------------------
		parentPanel.add(newPanel);
		parentPanel.validate();
		this.setPanelBounds(parentPanel);
		
		// --- Now move the rest of the elements on the form ----------------------------
		this.moveAfterAddOrRemove(movement, newNode);
		
	} else {
		// ----------------------------------------------------------------
		// --- The case for special classes, that have to be invisible ----
		// ----------------------------------------------------------------
		newPanel.setVisible(false);
		newPanel.setBounds(oldPanel.getBounds());
		
	}
	
	// --- refresh the GUI ----------------------------------------------------------
	this.adjustPreferredSize();
	
	return newNode;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:77,代碼來源:DynForm.java


注:本文中的javax.swing.tree.DefaultMutableTreeNode.removeFromParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。