本文整理汇总了Java中javax.swing.JPanel.getY方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getY方法的具体用法?Java JPanel.getY怎么用?Java JPanel.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.getY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPanelBounds
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Sets the bounds of the given panel, depending on the child components on this panel.
*
* @param panel the new panel bounds
*/
private void setPanelBounds(JPanel panel){
int xPos = panel.getX();
int yPos = panel.getY();
int maxX = 0;
int maxY = 0;
Component[] components = panel.getComponents();
for (int i = 0; i < components.length; i++) {
int currXMax = components[i].getX() + components[i].getWidth();
int currYMax = components[i].getY() + components[i].getHeight();
if (currXMax > maxX) maxX = currXMax;
if (currYMax > maxY) maxY = currYMax;
}
maxX += 5;
maxY += 2;
panel.setBounds(xPos, yPos, maxX, maxY);
}
示例2: 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;
}