本文整理汇总了Java中java.awt.Component.paint方法的典型用法代码示例。如果您正苦于以下问题:Java Component.paint方法的具体用法?Java Component.paint怎么用?Java Component.paint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.paint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCompImage
import java.awt.Component; //导入方法依赖的package包/类
private Image createCompImage(Component comp, Dimension targetSize) {
// component won't paint if not showing anyway, so don't create
// empty image but honestly return null
if (!comp.isShowing()) {
return null;
}
Image image = comp.createImage(comp.getWidth(), comp.getHeight());
/*BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().
createCompatibleImage(comp.getWidth(), comp.getHeight());*/
//BufferedImage image = new BufferedImage (targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D gr2d = (Graphics2D)image.getGraphics();
comp.paint(gr2d);
gr2d.dispose();
return image;
}
示例2: createContentImage
import java.awt.Component; //导入方法依赖的package包/类
private BufferedImage createContentImage( Component c, Dimension contentSize ) {
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage res = config.createCompatibleImage(contentSize.width, contentSize.height);
Graphics2D g = res.createGraphics();
//some components may be non-opaque so just black rectangle would be painted then
g.setColor( Color.white );
g.fillRect(0, 0, contentSize.width, contentSize.height);
if( WinSysPrefs.HANDLER.getBoolean(WinSysPrefs.DND_SMALLWINDOWS, true) && c.getWidth() > 0 && c.getHeight() > 0 ) {
double xScale = contentSize.getWidth() / c.getWidth();
double yScale = contentSize.getHeight() / c.getHeight();
g.setTransform(AffineTransform.getScaleInstance(xScale, yScale) );
}
c.paint(g);
return res;
}
示例3: createMenuIcon
import java.awt.Component; //导入方法依赖的package包/类
private static Icon createMenuIcon(Icon icon, Component decorator) {
int h = menuIconSize();
int w = UIUtils.isAquaLookAndFeel() ? h + 4 : h;
BufferedImage i = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = i.getGraphics();
if (decorator != null) {
decorator.setSize(w, h);
decorator.paint(g);
}
icon.paintIcon(null, g, (w - icon.getIconWidth()) / 2, (h - icon.getIconHeight()) / 2);
g.dispose();
return new ImageIcon(i);
}
示例4: drawRemaining
import java.awt.Component; //导入方法依赖的package包/类
private void drawRemaining(Rectangle rectangle, Component lp, BufferedImage pic) {
if ((rectangle.x + rectangle.width) > lp.getWidth()) {
rectangle.width = lp.getWidth() - rectangle.x;
}
if ((rectangle.y + rectangle.height) > lp.getHeight()) {
rectangle.height = lp.getHeight() - rectangle.y;
}
if (!rectangle.isEmpty()) {
Graphics g = pic.createGraphics();
g.translate(-rectangle.x, -rectangle.y);
g.setClip(rectangle);
boolean doubleBuffered = lp.isDoubleBuffered();
if (lp instanceof JComponent) {
((JComponent) lp).setDoubleBuffered(false);
lp.paint(g);
((JComponent) lp).setDoubleBuffered(doubleBuffered);
} else {
lp.paint(g);
}
g.dispose();
}
}
示例5: paintBorder
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
{
g.setColor(color);
g.fillRect(x, y, width, height);
if( c instanceof Container )
{
Container cont = (Container) c;
for( int i = 0, n = cont.getComponentCount(); i < n; i++ )
{
Component comp = cont.getComponent(i);
comp.getBounds(r);
Graphics tmpg = g.create(r.x, r.y, r.width, r.height);
comp.paint(tmpg);
tmpg.dispose();
}
}
}
示例6: paintComponent
import java.awt.Component; //导入方法依赖的package包/类
/** Workaround for excessive paints by SwingUtilities.paintComponent() */
private void paintComponent(Graphics g, Component c, int x, int y, int w, int h) {
c.setBounds(x, y, w, h);
g.translate(x, y);
c.paint(g);
g.translate(-x, -y);
c.setBounds(-w, -h, 0, 0);
}
示例7: getScreenShot
import java.awt.Component; //导入方法依赖的package包/类
private static BufferedImage getScreenShot(Component component) {
BufferedImage image = new BufferedImage(
component.getWidth(),
component.getHeight(),
BufferedImage.TYPE_INT_RGB);
// call the Component's paint method, using
// the Graphics object of the image.
component.paint( image.getGraphics() );
return image;
}
示例8: paintComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* Calls <code>Component.paint(Graphics)</code> with given Graphics.
*/
protected void paintComponent(Component comp, Graphics g) {
if (comp != null) {
comp.paint(g);
}
}
示例9: paintComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* Calls {@code Component.paint(Graphics)} with given Graphics.
*/
protected void paintComponent(Component comp, Graphics g) {
if (comp != null) {
comp.paint(g);
}
}
示例10: paintFrameToBufferedImage
import java.awt.Component; //导入方法依赖的package包/类
private void paintFrameToBufferedImage(Component component) {
component.paint(bi.getGraphics());
}