本文整理汇总了Java中javax.swing.JPanel.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getHeight方法的具体用法?Java JPanel.getHeight怎么用?Java JPanel.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.getHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: exportToImage
import javax.swing.JPanel; //导入方法依赖的package包/类
public static void exportToImage(String format, JPanel dPanel, String fileName) {
BufferedImage bImg = new BufferedImage(dPanel.getWidth(), dPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D cg = bImg.createGraphics();
dPanel.paintAll(cg);
try {
if (ImageIO.write(bImg, "jpg", new File("./" + fileName + "." + format)))
{
System.out.println("image saved succesfully");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: createOuterDeadEnd
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* This method creates a so called dead end. This means that originally a class
* should be displayed which was already displayed on a higher level in direction
* to the root node. This was realized to prevent the form generation to be run
* in an endless loop.
*
* @param oscsd the oscsd
* @param className the class name
* @param depth the depth
* @param pan the pan
* @param node the node
*/
private void createOuterDeadEnd(OntologySingleClassSlotDescription oscsd, String className, int depth, JPanel pan, DefaultMutableTreeNode node){
// --- this outer element has no parents which are inner classes
// --- so its added to the mainPanel
final JPanel dataPanel = new JPanel();
dataPanel.setLayout(null);
dataPanel.setToolTipText(oscsd.getSlotName() + "-Panel");
// --- add a JLabel to display the field's name
JLabel valueFieldText = new JLabel();
valueFieldText.setText("<html>" + oscsd.getSlotName() + " ["+oscsd.getSlotVarType()+"] - <b>" + Language.translate("Zyklisch !") + "</b></html>");
valueFieldText.setBounds(new Rectangle(0, 4, 330, 16));
// --- add both GUI elements to the panel
dataPanel.add(valueFieldText, null);
this.setPanelBounds(dataPanel);
DynType dynType = new DynType(oscsd, DynType.typeCyclic, className, dataPanel, oscsd.getSlotName(), null);
node.add(new DefaultMutableTreeNode(dynType));
// --- set the new position (increment the height) for the parent panel of the
// --- newly created panel
Rectangle pos = dataPanel.getBounds();
pos.x = 10;//tiefe * einrueckungProUntereEbene;
pos.y = pan.getHeight();
dataPanel.setBounds(pos);
pan.add(dataPanel);
this.setPanelBounds(pan);
}
示例4: 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;
}
示例5: gaze2pix
import javax.swing.JPanel; //导入方法依赖的package包/类
private Point gaze2pix(JPanel pan, Point2D.Float gaze) {
int h=pan.getHeight(), w=pan.getWidth();
// (g+1)/2 ranges 0:1
p2.setLocation((gaze.x + 1) / 2 * w, h-((gaze.y + 1) / 2 * h)); // y starts from top in AWT, so flip y here
return p2;
}