本文整理汇总了Java中javax.swing.JComponent.paint方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.paint方法的具体用法?Java JComponent.paint怎么用?Java JComponent.paint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.paint方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paint
import javax.swing.JComponent; //导入方法依赖的package包/类
public void paint(Graphics g) {
g.setColor(getBackground());
g.fillRect(location.x, location.y, size.width, size.height);
JComponent component = mainRenderer.getComponent();
int componentWidth = component.getPreferredSize().width;
int componentX = size.width - componentWidth;
mainRenderer.move(location.x + componentX, location.y);
component.setSize(componentWidth, size.height);
component.paint(g);
int freeWidth = size.width - maxRendererWidth - renderersGap();
if (freeWidth >= MIN_BAR_WIDTH) {
barRenderer.setSize(Math.min(freeWidth, MAX_BAR_WIDTH), size.height);
barRenderer.move(location.x, location.y);
barRenderer.paint(g);
}
}
示例3: createContentImage
import javax.swing.JComponent; //导入方法依赖的package包/类
private BufferedImage createContentImage( JComponent c, Dimension contentSize ) {
GraphicsConfiguration cfg = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
boolean opaque = c.isOpaque();
c.setOpaque(true);
BufferedImage res = cfg.createCompatibleImage(contentSize.width, contentSize.height);
Graphics2D g = res.createGraphics();
g.setColor( c.getBackground() );
g.fillRect(0, 0, contentSize.width, contentSize.height);
g.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f ));
c.paint(g);
c.setOpaque(opaque);
return res;
}
示例4: render
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void render(Graphics graphics, int width, int height) {
JComponent renderComponent = getRenderComponent();
renderComponent.setSize(width, height);
renderComponent.setDoubleBuffered(false);
renderComponent.paint(graphics);
renderComponent.setDoubleBuffered(true);
}
示例5: getAreaAsImage
import javax.swing.JComponent; //导入方法依赖的package包/类
public static BufferedImage getAreaAsImage(final int w, final int h, final JComponent component) {
final int type = BufferedImage.TYPE_INT_RGB;
final BufferedImage image = new BufferedImage(w, h, type);
final Graphics2D g2 = image.createGraphics();
component.paint(g2);
g2.dispose();
return image;
}
示例6: getImage
import javax.swing.JComponent; //导入方法依赖的package包/类
static BufferedImage getImage(JComponent component, int scale, int width, int height) {
final BufferedImage image = new BufferedImage(
scale * width, scale * height, BufferedImage.TYPE_INT_ARGB);
final Graphics g = image.getGraphics();
((Graphics2D) g).scale(scale, scale);
component.paint(g);
g.dispose();
return image;
}
示例7: getImage
import javax.swing.JComponent; //导入方法依赖的package包/类
static Image getImage(JComponent component) {
final BufferedImage image = new BufferedImage(
scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
final Graphics g = image.getGraphics();
((Graphics2D) g).scale(scale, scale);
component.paint(g);
g.dispose();
return image;
}
示例8: paintToImage
import javax.swing.JComponent; //导入方法依赖的package包/类
private static void paintToImage(JComponent comp) {
BufferedImage image = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
comp.paint(g);
g.dispose();
}
示例9: 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);
}
}