List of usage examples for javax.swing JComponent setSize
public void setSize(int width, int height)
From source file:com.projity.pm.graphic.network.NetworkRenderer.java
public void paintNode(Graphics2D g, GraphicNode node) { Rectangle bounds = getBounds(node); if (isEditing(node)) { editor.paintEditor(node);//w w w. j a v a2 s. c o m } else { JComponent c = renderer.getRendererComponent(node, ((NetworkParams) graphInfo).getZoom()); if (container == null) { //c=new JLabel("test"); c.setDoubleBuffered(false); c.setOpaque(false); c.setForeground(Color.BLACK); c.setSize(bounds.width, bounds.height); g.translate(bounds.x, bounds.y); c.doLayout(); c.print(g); g.translate(-bounds.x, -bounds.y); } else rendererPane.paintComponent(g, c, container, bounds.x, bounds.y, bounds.width, bounds.height, true); } }
From source file:org.mwc.cmap.xyplot.views.XYPlotView.java
protected void bitmapToClipBoard(JComponent component) { Point size = _plotControl.getSize(); final BufferedImage img = new BufferedImage(size.x, size.y, BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); g.setColor(component.getForeground()); g.setFont(component.getFont());//from w w w . j a v a 2s . com component.setSize(size.x, size.y); component.paint(g); Transferable t = new Transferable() { public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { DataFlavor.imageFlavor }; } public boolean isDataFlavorSupported(DataFlavor flavor) { if (flavor == DataFlavor.imageFlavor) return true; return false; } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if (isDataFlavorSupported(flavor)) { return img; } return null; } }; ClipboardOwner co = new ClipboardOwner() { public void lostOwnership(java.awt.datatransfer.Clipboard clipboard, Transferable contents) { } }; java.awt.datatransfer.Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(t, co); }