List of usage examples for java.awt Graphics2D fillRect
public abstract void fillRect(int x, int y, int width, int height);
From source file:GradientsMiddle.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(0, 0, Color.orange, 0, 20, Color.black, true); g2d.setPaint(gp1);/* w w w . j a v a 2 s .com*/ g2d.fillRect(20, 260, 300, 40); }
From source file:GradientsDirection.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 25, Color.yellow, 20, 2, Color.black, true); g2d.setPaint(gp1);//from ww w . ja v a 2 s .c o m g2d.fillRect(20, 80, 300, 40); }
From source file:GradientsVertical.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(25, 25, Color.blue, 15, 25, Color.black, true); g2d.setPaint(gp1);// w w w .j a va2 s . c o m g2d.fillRect(20, 200, 300, 40); }
From source file:AffineTransformGetShearInstance.java
public void paint(Graphics g) { AffineTransform atrans = null; Graphics2D g2d = (Graphics2D) g; atrans = AffineTransform.getShearInstance(.1, .5); if (atrans != null) g2d.setTransform(atrans);/* www . j a va 2 s . c o m*/ g2d.fillRect(50, 50, 100, 50); }
From source file:misc.GradientTranslucentWindowDemo.java
public GradientTranslucentWindowDemo() { super("GradientTranslucentWindow"); setBackground(new Color(0, 0, 0, 0)); setSize(new Dimension(300, 200)); setLocationRelativeTo(null);//w w w . j av a 2 s . c o m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { if (g instanceof Graphics2D) { final int R = 240; final int G = 240; final int B = 240; Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0), 0.0f, getHeight(), new Color(R, G, B, 255), true); Graphics2D g2d = (Graphics2D) g; g2d.setPaint(p); g2d.fillRect(0, 0, getWidth(), getHeight()); } } }; setContentPane(panel); setLayout(new GridBagLayout()); add(new JButton("I am a Button")); }
From source file:TransparentRectangles.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; for (int i = 1; i <= 10; i++) { g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, i * 0.1f)); g2d.fillRect(50 * i, 20, 50, 50); }//w w w. ja va 2 s. c o m }
From source file:Rectangles.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(212, 212, 212)); g2d.drawRect(10, 15, 90, 60);/*from ww w . j av a2 s . c o m*/ g2d.setColor(new Color(31, 21, 1)); g2d.fillRect(250, 195, 90, 60); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; GradientPaint p = new GradientPaint(0, 0, Color.white, getWidth(), getHeight(), Color.gray); g2d.setPaint(p);// w w w . j a v a2 s . c om g2d.fillRect(0, 0, getWidth(), getHeight()); }
From source file:AffineTransformGetRotateInstance.java
public void paint(Graphics g) { AffineTransform atrans = null; Graphics2D g2d = (Graphics2D) g; atrans = AffineTransform.getRotateInstance(Math.PI / 4, 50, 50); if (atrans != null) g2d.setTransform(atrans);/*from www . j a va 2 s . c o m*/ g2d.fillRect(50, 50, 100, 50); }
From source file:com.tdclighthouse.prototype.servlets.JLatexServlet.java
private synchronized BufferedImage generateImage(String latex) { TeXFormula formula = new TeXFormula(latex); TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20); icon.setInsets(new Insets(5, 5, 5, 5)); BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); g2.setColor(Color.white);/*from w w w . ja va2 s .c o m*/ g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); JLabel jl = new JLabel(); jl.setForeground(new Color(0, 0, 0)); icon.paintIcon(jl, g2, 0, 0); return image; }