Example usage for java.awt Color RED

List of usage examples for java.awt Color RED

Introduction

In this page you can find the example usage for java.awt Color RED.

Prototype

Color RED

To view the source code for java.awt Color RED.

Click Source Link

Document

The color red.

Usage

From source file:Main.java

public void buildChooser() {
    setLayout(new GridLayout(0, 3));
    makeAddButton("Red", Color.red);
    makeAddButton("Green", Color.green);
    makeAddButton("Blue", Color.blue);
}

From source file:Main.java

public static ImageIcon createImage() {
    BufferedImage image = new BufferedImage(28, 28, BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.getGraphics();
    g.setColor(Color.RED);
    g.fillRect(0, 0, 32, 32);//from ww  w. j av  a 2s .co m
    g.dispose();
    return new ImageIcon(image);
}

From source file:TransparentText.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // the rendering quality.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    // a red rectangle.
    Rectangle2D r = new Rectangle2D.Double(50, 50, 550, 100);
    g2.setPaint(Color.red);
    g2.fill(r);//w w w .  j  av a  2 s.  c o  m
    // a composite with transparency.
    Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .4f);
    g2.setComposite(c);
    // Draw some blue text.
    g2.setPaint(Color.blue);
    g2.setFont(new Font("Times New Roman", Font.PLAIN, 72));
    g2.drawString("Java Source and Support", 25, 130);
}

From source file:CompoundBorderLabel.java

public CompoundBorderLabel() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border border1 = new CompoundBorder(LineBorder.createBlackLineBorder(),
            BorderFactory.createLineBorder(Color.red, 20));

    Border border2 = new CompoundBorder(border1, BorderFactory.createLoweredBevelBorder());

    label.setBorder(border2);//from  ww  w.j  av a2s . c om
    getContentPane().add(label, BorderLayout.CENTER);
    pack();
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setPaint(Color.black);//  w w  w .  j  av  a  2  s.  c o  m
    g2.draw(new Rectangle2D.Float(10, 20, 30, 40));

    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);

    g2.setPaint(Color.red);
    g2.draw(new Rectangle2D.Float(10, 20, 30, 40));
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setPaint(Color.black);/*from w  ww . j a  v  a  2 s  . c  o m*/
    g2.draw(new Rectangle2D.Float(10, 20, 30, 40));

    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.setTransform(at);

    g2.setPaint(Color.red);
    g2.draw(new Rectangle2D.Float(10, 20, 30, 40));
}

From source file:TimerChangeButtonBackground.java

public TimerChangeButtonBackground() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(button, "Center");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            timer.stop();//from   ww  w  .j  a va 2  s.c om
            button.setBackground(Color.red);
        }
    });
    timer = new Timer(1000, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            button.setBackground(flag ? Color.green : Color.yellow);
            flag = !flag;
            repaint();
        }
    });
    timer.start();
    pack();
    setVisible(true);
}

From source file:MyCanvas.java

public void draw(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Draw the pie chart
    Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE);
    arc.setFrame(140, 200, 67, 46);/*  w  w  w  . java2 s  .co m*/
    arc.setAngleStart(45);
    arc.setAngleExtent(270);
    g2.setColor(Color.gray);
    g2.draw(arc);
    g2.setColor(Color.red);
    g2.fill(arc);
    g2.setColor(Color.black);
    g2.drawString("Arc2D.PIE", 140, 190);
}

From source file:CardLayoutBehaviour.java

public CardLayoutBehaviour() {
    JPanel tab;//ww w  .  j av a 2 s.com
    Container pane = getContentPane();
    layout = new CardLayout();
    pane.setLayout(layout);
    tab = new JPanel();
    tab.setBackground(Color.red);
    pane.add(tab, "Red Tab");
    tab = new JPanel();
    tab.setBackground(Color.green);
    pane.add(tab, "Green Tab");
    tab = new JPanel();
    tab.setBackground(Color.blue);
    pane.add(tab, "Blue Tab");
}

From source file:org.jfree.graphics2d.demo.ImageTest.java

private static void drawLinearGradientPaintTest(Graphics2D g2) {
    // top left/*from  w ww .j a v  a 2  s  .  c  o  m*/
    LinearGradientPaint lgp = new LinearGradientPaint(10, 30, 50, 30, new float[] { 0.0f, 1.0f },
            new Color[] { Color.RED, Color.BLUE });
    g2.setPaint(lgp);
    g2.fill(new Rectangle2D.Double(10, 10, 40, 40));

    // top right
    lgp = new LinearGradientPaint(80, 10, 80, 50, new float[] { 0.0f, 1.0f },
            new Color[] { Color.RED, Color.BLUE });
    g2.setPaint(lgp);
    g2.fill(new Rectangle2D.Double(60, 10, 40, 40));

    // bottom left
    lgp = new LinearGradientPaint(10, 100, 50, 60, new float[] { 0.0f, 1.0f },
            new Color[] { Color.RED, Color.BLUE });
    g2.setPaint(lgp);
    g2.fill(new Rectangle2D.Double(10, 60, 40, 40));

    // bottom right
    lgp = new LinearGradientPaint(70, 70, 90, 90, new float[] { 0.0f, 0.5f, 1.0f },
            new Color[] { Color.RED, Color.YELLOW, Color.BLUE }, CycleMethod.REPEAT);
    g2.setPaint(lgp);
    g2.fill(new Rectangle2D.Double(60, 60, 40, 40));

}