当前位置: 首页>>代码示例>>Java>>正文


Java Component.paint方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ScaleFx.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DragWindow.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ToggleButtonMenuItem.java

示例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();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:RoundedRectanglePopup.java

示例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();
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:AppletGuiUtils.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SheetTable.java

示例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;
}
 
开发者ID:jspacco,项目名称:gridLib,代码行数:11,代码来源:SimpleGrid.java

示例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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:RepaintArea.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:RepaintArea.java

示例10: paintFrameToBufferedImage

import java.awt.Component; //导入方法依赖的package包/类
private void paintFrameToBufferedImage(Component component) {
   component.paint(bi.getGraphics());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:SynthScrollbarThumbPainterTest.java


注:本文中的java.awt.Component.paint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。