本文整理汇总了Java中javax.swing.JComponent.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.setBounds方法的具体用法?Java JComponent.setBounds怎么用?Java JComponent.setBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.setBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
public void paintComponent(Graphics g) {
//Hack for issue 38132 - Beans are set via TTVBridge as a package
//private property on the parent PropertyPanel (if there is one).
//FindBeans() will locate the beans either in the model or as a
//property of the PropertyPanel (if an esoteric undocumented client property
//is set on the PropertyPanel). RendererFactory will set the env
//value (if there is an env) to the value of ReusablePropertyEnv.NODE
//(a performance hack to avoid creating 1 property env for each property
//painted each time we paint). Cool, huh?
reusableEnv.setNode(EditorPropertyDisplayer.findBeans(this));
JComponent comp = getRenderer(this);
prepareRenderer(comp);
comp.setBounds(0, 0, getWidth(), getHeight());
if (comp instanceof InplaceEditor) {
Component inner = findInnermostRenderer(comp);
SwingUtilities.paintComponent(g, comp, this, 0, 0, getWidth(), getHeight());
removeAll();
return;
}
comp.paint(g);
}
示例2: prepareRenderer
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void prepareRenderer(JComponent comp) {
comp.setBackground(getBackground());
comp.setForeground(getForeground());
comp.setBounds(0, 0, getWidth(), getHeight());
JComponent innermost;
if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) {
if (comp.getLayout() != null) {
comp.getLayout().layoutContainer(comp);
}
}
if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) {
innermost.setBackground(PropUtils.getTextFieldBackground());
innermost.setForeground(PropUtils.getTextFieldForeground());
}
}
示例3: createImageOfComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
private BufferedImage createImageOfComponent() {
if (USE_SWINGPAINTING) {
return null;
}
if (d.width == 0 || d.height == 0) {
//Avoid problems in native graphics engine scaling if we should
//end up with crazy values
finish();
}
BufferedImage img =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().
createCompatibleImage(d.width, d.height);
Graphics2D g2d = img.createGraphics();
JComponent c = tabDisplayer;
c.setBounds (0, 0, d.width, d.height);
comp.paint (g2d);
return img;
}
示例4: paintComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void paintComponent(Graphics g) {
JTableHeader header = getHeader();
setupHeader(header);
TableCellRenderer renderer = header.getDefaultRenderer();
JComponent component = (JComponent)renderer.getTableCellRendererComponent(
getTable(), "", isSelected && isPressed, isFocusOwner(), -1, 0); // NOI18N
int height = header.getPreferredSize().height;
component.setBounds(0, 0, getWidth(), height);
component.setOpaque(false);
getPainter().paintComponent(g, component, null, 0, 0, getWidth(), height, false);
}
示例5: layoutContainer
import javax.swing.JComponent; //导入方法依赖的package包/类
public void layoutContainer(Container c) {
Insets insets = c.getInsets();
int labelWidth = 0;
for (Component comp : labels) {
labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
}
int yPos = insets.top;
Iterator<Component> fieldIter = fields.listIterator();
Iterator<Component> labelIter = labels.listIterator();
while (labelIter.hasNext() && fieldIter.hasNext()) {
JComponent label = (JComponent) labelIter.next();
JComponent field = (JComponent) fieldIter.next();
int height = Math.max(label.getPreferredSize().height, field.
getPreferredSize().height);
label.setBounds(insets.left, yPos, labelWidth, height);
field.setBounds(insets.left + labelWidth + xGap,
yPos,
c.getSize().width - (labelWidth + xGap + insets.left
+ insets.right),
height);
yPos += (height + yGap);
}
}
示例6: layoutContainer
import javax.swing.JComponent; //导入方法依赖的package包/类
public void layoutContainer(Container parent) {
JComponent c = tabDisplayer;
Object orientation = c.getClientProperty (
TabDisplayer.PROP_ORIENTATION);
Dimension d = tabDisplayer.getPreferredSize();
Insets ins = container.getInsets();
int width = parent.getWidth() - (ins.left + ins.right);
int height = parent.getHeight() - (ins.top + ins.bottom);
if (orientation == TabDisplayer.ORIENTATION_NORTH) {
c.setBounds (ins.left, ins.top,
width, d.height);
contentDisplayer.setBounds (ins.left, ins.top + d.height,
width,
parent.getHeight() - (d.height + ins.top + ins.bottom));
} else if (orientation == TabDisplayer.ORIENTATION_SOUTH) {
contentDisplayer.setBounds (ins.top, ins.left, width,
parent.getHeight() - (d.height + ins.top + ins.bottom));
c.setBounds (ins.left, parent.getHeight() - (d.height + ins.top + ins.bottom),
width, d.height);
} else if (orientation == TabDisplayer.ORIENTATION_EAST) {
contentDisplayer.setBounds (ins.left, ins.top, width - d.width,
height);
c.setBounds (parent.getWidth() - (ins.right + d.width), ins.top,
d.width, height);
} else if (orientation == TabDisplayer.ORIENTATION_WEST) {
c.setBounds (ins.left, ins.top, d.width, height);
contentDisplayer.setBounds (ins.left + d.width, ins.top,
width - d.width, height);
} else {
throw new IllegalArgumentException ("Unknown orientation: " + orientation);
}
}
示例7: dragGestureRecognized
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public final void dragGestureRecognized(DragGestureEvent dge) {
TreePath path = tree.getSelectionPath();
if (path != null) {
draggedNode = path.getLastPathComponent();
if (drawImage) {
Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds
// of
// selectionpath
JComponent lbl = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree, draggedNode,
false, tree.isExpanded(path), tree.getModel().isLeaf(path.getLastPathComponent()), 0,
false);// returning the label
lbl.setBounds(pathBounds);// setting bounds to lbl
image = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);// buffered
// image
// reference
// passing
// the
// label's
// ht
// and
// width
Graphics2D graphics = image.createGraphics();// creating
// the
// graphics
// for
// buffered
// image
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); // Sets
// the
// Composite
// for
// the
// Graphics2D
// context
lbl.setOpaque(false);
lbl.paint(graphics); // painting the graphics to label
graphics.dispose();
}
dragSource.startDrag(dge, DragSource.DefaultMoveNoDrop, image, new Point(0, 0),
new TransferableNode(draggedNode), this);
}
}
示例8: setButtonByCenterLeft
import javax.swing.JComponent; //导入方法依赖的package包/类
private void setButtonByCenterLeft(JComponent button, int x, int y)
{
Dimension butsize = button.getPreferredSize();
butsize.height = 20;
button.setBounds(x+11, y-butsize.height+2, butsize.width, butsize.height);
}