当前位置: 首页>>代码示例>>Java>>正文


Java JPanel.getParent方法代码示例

本文整理汇总了Java中javax.swing.JPanel.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getParent方法的具体用法?Java JPanel.getParent怎么用?Java JPanel.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.getParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeMultiple

import javax.swing.JPanel; //导入方法依赖的package包/类
@Override
protected void removeMultiple(DefaultMutableTreeNode node){
	
	// --- Remind all needed informations -------------------------------------------
	DefaultMutableTreeNode previousNode = node.getPreviousNode();
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
	
	DynType dt = (DynType) node.getUserObject();
	JPanel deletePanel = dt.getPanel();
	JPanel parentPanel = (JPanel) deletePanel.getParent();
	
	int movement = (deletePanel.getHeight() + 2) * (-1);
	
	// --- Remove node from the parent node and panel -------------------------------
	DynType dyntype = (DynType) node.getUserObject();
	node.setUserObject(null);
	parentNode.remove(node);
	this.getTreeNodesByDynType().remove(dyntype);
	
	// --- remove the panel from the parent -----------------------------------------
	parentPanel.remove(deletePanel);
	parentPanel.validate();
	this.setPanelBounds(parentPanel);
	
	// --- Now move the rest of the elements on the form ----------------------------
	this.moveAfterAddOrRemove(movement, previousNode);

	// --- refresh the GUI ----------------------------------------------------------
	this.adjustPreferredSize();
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:32,代码来源:DynForm.java

示例2: openParents

import javax.swing.JPanel; //导入方法依赖的package包/类
private void openParents(JPanel panel){
    javax.swing.JScrollPane scrollP = null;
    NodeSectionPanel parentSection=null;
    java.awt.Container ancestor = panel.getParent();
    while (ancestor !=null && scrollP == null){
        if (ancestor instanceof javax.swing.JScrollPane){
            scrollP = (javax.swing.JScrollPane) ancestor;
        }
        if (ancestor instanceof NodeSectionPanel){
            parentSection = (NodeSectionPanel) ancestor;
            parentSection.open();
        }
        ancestor = ancestor.getParent();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:SectionView.java

示例3: addSingleMultipleNode

import javax.swing.JPanel; //导入方法依赖的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

示例4: moveAfterAddOrRemove

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * Move all elements which are available after the node given by the parameter node.
 *
 * @param movement the movement
 * @param node the node
 */
private void moveAfterAddOrRemove(int movement, DefaultMutableTreeNode node) {
	
	if (node==this.getRootNode()) return;
	
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
	JPanel parentPanel = null;
	if (parentNode.getUserObject() instanceof DynType) {
		DynType dynType = (DynType) parentNode.getUserObject();
		parentPanel = dynType.getPanel();
	}
	
	int numOfChilds = parentNode.getChildCount();
	int indexOfNextNode = parentNode.getIndex(node) + 1;
	
	for (int i = indexOfNextNode; i < numOfChilds; i++) {
		
		DefaultMutableTreeNode currNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);

		DynType dt = (DynType) currNode.getUserObject();
		JPanel movePanel = dt.getPanel();
		movePanel.setBounds(movePanel.getX(), movePanel.getY()+movement, movePanel.getWidth(), movePanel.getHeight());
		
		JComponent parentComp = (JComponent) movePanel.getParent();
		parentComp.validate();
		if (parentComp instanceof JPanel) {
			this.setPanelBounds((JPanel) parentComp);	
		}
		
	}

	// --- Configure size of parent panel -----------------------
	if (parentPanel!=null) {
		parentPanel.validate();
		this.setPanelBounds(parentPanel);
	}
	
	// --- do the same at the parent node -----------------------
	this.moveAfterAddOrRemove(movement, parentNode);
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:47,代码来源:DynForm.java


注:本文中的javax.swing.JPanel.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。