Java Code Examples for java.awt.Component#paint()
The following examples show how to use
java.awt.Component#paint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnapshotTool.java From osp with GNU General Public License v3.0 | 6 votes |
/** * Constructor ComponentImage * @param comp */ public ComponentImage(Component comp) { c = comp; if(comp instanceof JFrame) { comp = ((JFrame) comp).getContentPane(); } else if(comp instanceof JDialog) { comp = ((JDialog) comp).getContentPane(); } image = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_3BYTE_BGR); if(comp instanceof Renderable) { image = ((Renderable) comp).render(image); } else { java.awt.Graphics g = image.getGraphics(); comp.paint(g); g.dispose(); } }
Example 2
Source File: ToggleButtonMenuItem.java From visualvm with GNU General Public License v2.0 | 6 votes |
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); }
Example 3
Source File: ScaleFx.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: AbstractImageEncoder.java From tn5250j with GNU General Public License v2.0 | 5 votes |
public static Image snapshot(Component component) { Image img = component.createImage(component.getSize().width, component.getSize().height); if (img != null) { Graphics igc = img.getGraphics(); //Gotta set the clip, or else paint throws an exception igc.setClip(0, 0, component.getSize().width, component.getSize().height); component.paint(igc); } return img; }
Example 5
Source File: AbstractDockingTest.java From ghidra with Apache License 2.0 | 5 votes |
private static Image doCreateRenderedImage(Component c) { Rectangle r = c.getBounds(); BufferedImage bufferedImage = new BufferedImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB); Graphics graphics = bufferedImage.getGraphics(); c.paint(graphics); graphics.dispose(); return bufferedImage; }
Example 6
Source File: GhostComponentAdapter.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
@Override public void mousePressed (MouseEvent e) { Component c = e.getComponent(); // Copy the component current appearance image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = image.getGraphics(); c.paint(g); // Standard processing super.mousePressed(e); }
Example 7
Source File: ComponentApprovalWriter.java From ApprovalTests.Java with Apache License 2.0 | 5 votes |
public static BufferedImage drawComponent(Component c) { validateComponent(c); BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = image.createGraphics(); c.paint(g); g.dispose(); return image; }
Example 8
Source File: SheetTable.java From netbeans with Apache License 2.0 | 5 votes |
/** 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); }
Example 9
Source File: Print.java From wandora with GNU General Public License v3.0 | 5 votes |
public void print(Component component) { if(component != null) { BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); if(component instanceof JComponent) { ((JComponent) component).setDoubleBuffered(false); } component.paint(g); if(component instanceof JComponent) { ((JComponent) component).setDoubleBuffered(true); } printImage(image); } }
Example 10
Source File: ImageHelper.java From magarena with GNU General Public License v3.0 | 4 votes |
private static BufferedImage getScreenshotImage(final Component container) { final Rectangle rec = container.getBounds(); final BufferedImage capture = getCompatibleBufferedImage(rec.width, rec.height); container.paint(capture.getGraphics()); return capture; }
Example 11
Source File: RepaintArea.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Calls <code>Component.paint(Graphics)</code> with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }
Example 12
Source File: RepaintArea.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Calls <code>Component.paint(Graphics)</code> with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }
Example 13
Source File: ExampleUtils.java From astor with GNU General Public License v2.0 | 4 votes |
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; }
Example 14
Source File: RepaintArea.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Calls {@code Component.paint(Graphics)} with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }
Example 15
Source File: SynthScrollbarThumbPainterTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void paintFrameToBufferedImage(Component component) { component.paint(bi.getGraphics()); }
Example 16
Source File: RepaintArea.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Calls <code>Component.paint(Graphics)</code> with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }
Example 17
Source File: ExampleUtils.java From astor with GNU General Public License v2.0 | 4 votes |
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; }
Example 18
Source File: RepaintArea.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Calls <code>Component.paint(Graphics)</code> with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }
Example 19
Source File: ExampleUtils.java From hipparchus with Apache License 2.0 | 4 votes |
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; }
Example 20
Source File: RepaintArea.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Calls <code>Component.paint(Graphics)</code> with given Graphics. */ protected void paintComponent(Component comp, Graphics g) { if (comp != null) { comp.paint(g); } }