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


Java JComponent.paint方法代码示例

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

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

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

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

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

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:bug8032667_image_diff.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:bug8032667.java

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

示例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);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:45,代码来源:JTreeUtil.java


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