public class MyCanvas extends JComponent { protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fill3DRect(20, 20, 200, 200,true); } }
@Override public void paintIcon(Component arg0, Graphics graphics, int x, int y) { graphics.setColor(this.color); graphics.fill3DRect(x, y, size, size, true); }
public void paint(Graphics g){ int height = 100; int width = 100; int x = (this.getWidth() / 2) - (width / 2); int y = (this.getHeight() / 2) - (height / 2); g.setColor(Color.BLACK); g.fill3DRect(x, y, width, height, true); }
@Override protected void paintComponent(Graphics g) { g.setColor(color); g.fill3DRect(0, 0, SIZE, SIZE, raised); if (marked) { g.setColor(LayerButton.SELECTED_COLOR); g.fillRect(1, 1, 7, 7); g.setColor(LayerButton.UNSELECTED_COLOR); g.fillRect(3, 3, 3, 3); } }
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(3, 8, 19, 104, false); } public void setAvgValue(int value) {
public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new JComponent() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.GRAY); for (int x = 0; x < getWidth(); x += 32) for (int y = 0; y < getHeight(); y += 32) g.fill3DRect(x+1, y+1, 30, 30, true); } }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600, 600); frame.setVisible(true); }
/** Do the drawing (called automagically by window system when needed) */ @Override public void paintComponent(Graphics g) { g.setColor(Color.white); Dimension d = getSize(); g.fill3DRect(0, 0, d.width-1, d.height-1, true); g.setFont(f); g.setColor(Color.red); g.drawString("Welcome", 100, 150); g.drawString("to", 240, 275); g.drawString("Java", 160, 400); }
/** * Utility method to paint the folding icon for groups. * * @param g * The graphics to paint the border to. */ protected void paintFoldingIcon(Graphics g) { if (isGroup) { g.setColor(graphBackground); g.fill3DRect(handle.x, handle.y, handle.width, handle.height, true); g.setColor(graphForeground); g.drawRect(handle.x, handle.y, handle.width, handle.height); int h2 = handle.y + handle.height / 2; g.drawLine(handle.x + 1, h2, handle.x + handle.width - 2, h2); if (view.isLeaf()) { int w2 = handle.x + handle.width / 2; g.drawLine(w2, handle.y + 1, w2, handle.y + handle.height - 2); } } }
public void paintIcon(Component _c, Graphics _g, int _x, int _y) { if(icon_!=null) icon_.paintIcon(_c,_g,_x,_y); else { Color cold=_g.getColor(); Font fold=_g.getFont(); int w=getIconWidth(); int h=getIconHeight(); _g.setColor(Color.lightGray); _g.fill3DRect(_x+1,_y+1,w-2,h-2,true); _g.setColor(Color.black); _g.drawRect(_x,_y,w-1,h-1); _g.setColor(cold); _g.setFont(fold); } }
@Override protected void paintWidget() { super.paintWidget(); Graphics g = getGraphics().create(); g.setColor(Color.RED); g.fill3DRect(4, 4, 4, 4, true); g.dispose(); } }
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); } /**
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); } /**
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); }
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); } /**
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); } /**
public void paint(java.awt.Graphics g) { g.setColor(getBackground()); g.fill3DRect(0, 0, getBounds().width, getBounds().height, true); } /**
@Override public void paint(Graphics g) { super.paint(g); if (value != null) { g.setColor(value); Rectangle r = getBounds(); r.grow(-5, -5); g.fill3DRect(r.x, r.y, r.width, r.height, true); } } };
@Override public void paint(Graphics g) { super.paint(g); if (value != null) { g.setColor(value); Rectangle r = getBounds(); r.grow(-5, -5); g.fill3DRect(r.x, r.y, r.width, r.height, true); } } };
public void paint(Graphics g) { invalidate(); g.setColor((editing) ? graph.getLockedHandleColor() : graph .getHandleColor()); for (int i = 0; i < r.length; i++) { if (cursors[i] != 0) g .fill3DRect((int) r[i].getX(), (int) r[i].getY(), (int) r[i].getWidth(), (int) r[i] .getHeight(), true); } if (!graph.isXorEnabled()) { firstOverlayInvocation = false; overlay(g); } }
/** * Paint the renderer. Overrides superclass paint to add specific painting. * Note: The preview flag is interpreted as "highlight" in this context. * (This is used to highlight the port if the mouse is over it.) */ public void paint(Graphics g) { Dimension d = getSize(); if (xorEnabled) { g.setColor(graphBackground); g.setXORMode(graphBackground); } super.paint(g); if (preview) { g.fill3DRect(0, 0, d.width, d.height, true); } else { g.fillRect(0, 0, d.width, d.height); } boolean offset = (GraphConstants.getOffset(view.getAllAttributes()) != null); g.setColor(getForeground()); if (!offset) g.fillRect(1, 1, d.width - 2, d.height - 2); else if (!preview) g.drawRect(1, 1, d.width - 3, d.height - 3); }