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:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*from  ww  w. j a  va  2s. co  m*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_IN));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.DST_IN", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*w  w w. j a v a2  s. c o  m*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.DST_OVER", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/* w  ww  .j a  v a2  s  .  c o  m*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.CLEAR", x, y + 80);

}

From source file:TextAttributesColor.java

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    AttributedString as1 = new AttributedString("1234567890");
    as1.addAttribute(TextAttribute.FOREGROUND, Color.red, 0, 2);
    g2d.drawString(as1.getIterator(), 15, 60);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel("TITLE BORDERS", JLabel.CENTER);
    titleLabel.setForeground(Color.red.darker());

    add(simplePanel);/*from www .  j  a  va2  s.  c o m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
    ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage("matte.gif"));
    simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
            BorderFactory.createMatteBorder(-1, -1, -1, -1, icon)));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*from ww  w  .j a  va 2 s  .co m*/
}

From source file:RedBlueBox.java

public void paintComponent(Graphics g) {
    Insets insets = getInsets();/*www.  j a  v a2 s.  c  om*/
    int endX = getWidth() - insets.right;
    int endY = getHeight() - insets.bottom;
    // get the top-left corner
    int x = insets.left;
    int y = insets.top;

    g.setColor(Color.RED);
    Polygon p = new Polygon();
    p.addPoint(x, y);
    p.addPoint(endX, y);
    p.addPoint(x, endY);
    g.fillPolygon(p);
    g.setColor(Color.BLUE);
    p.reset();
    p.addPoint(endX, y);
    p.addPoint(x, endY);
    p.addPoint(endX, endY);
    g.fillPolygon(p);
}

From source file:Main.java

public Main() {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setContentType("text/HTML");
    editorPane.setEditorKit(new HTMLEditorKit());
    editorPane.setText("<hr>Welcome to <b>java2s.com!</b><hr>");
    JToolBar bar = new JToolBar();
    bar.add(new StyledEditorKit.ForegroundAction("Red", Color.red));
    bar.add(new StyledEditorKit.ForegroundAction("Blue", Color.blue));
    bar.add(new StyledEditorKit.FontSizeAction("12", 12));
    bar.add(new StyledEditorKit.FontSizeAction("14", 14));
    bar.add(new StyledEditorKit.FontSizeAction("16", 16));
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setLocationRelativeTo(null);
    this.add(bar, BorderLayout.NORTH);
    this.add(editorPane, BorderLayout.CENTER);
    this.pack();//from   w ww.  j  a  v  a  2 s . c o  m
    this.setVisible(true);
}

From source file:BasicDraw.java

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

    Color startColor = Color.red;
    Color endColor = Color.blue;

    int startX = 10, startY = 20, endX = 30, endY = 40;

    GradientPaint gradient = new GradientPaint(startX, startY, startColor, endX, endY, endColor);
    g2d.setPaint(gradient);/* w  w w.j a  v  a 2 s.  c  o m*/

    g2d.draw(new Rectangle(20, 20, 200, 200));

}

From source file:BasicShapes.java

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

    int x = 10, y = 10, start = 2, end = 4;

    AttributedString astr = new AttributedString("aString");
    astr.addAttribute(TextAttribute.FONT, new Font("", 1, 1), start, end);
    astr.addAttribute(TextAttribute.BACKGROUND, Color.red, start, end);

    // Draw mixed-style text
    TextLayout tl = new TextLayout(astr.getIterator(), g2d.getFontRenderContext());
    tl.draw(g2d, x, y);/* w  ww.  ja va  2 s.co  m*/

}