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

public static void main(String[] args) {
    Document document = new Document();

    try {// ww  w. j a v a 2 s .c  om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("StatePDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        cb.setColorFill(Color.red);
        cb.circle(250.0f, 500.0f, 250.0f);
        cb.fill();
        cb.saveState();

        cb.setColorFill(Color.BLACK);
        cb.circle(350.0f, 500.0f, 200.0f);
        cb.fill();
        cb.saveState();

        cb.setColorFill(Color.blue);
        cb.circle(460.0f, 500.0f, 150.0f);
        cb.fill();

        cb.restoreState();
        cb.circle(560.0f, 500.0f, 100.0f);
        cb.fill();

        cb.restoreState();
        cb.circle(660.0f, 500.0f, 50.0f);
        cb.fill();
    } catch (Exception de) {
        System.err.println(de.getMessage());
    }
    document.close();
}

From source file:IconMatteBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Icon Matted Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Icon diamondIcon = new DiamondIcon(Color.red, true, 10, 10);
    Border diamondBorder = new MatteBorder(10, 10, 10, 10, diamondIcon);
    JButton diamondButton = new JButton("diamonds");
    diamondButton.setBorder(diamondBorder);
    Icon diamondIcon2 = new ImageIcon("diamond.gif");
    Border diamondBorder2 = new MatteBorder(36, 40, 36, 40, diamondIcon2);
    JButton diamondButton2 = new JButton("diamonds2");
    diamondButton2.setBorder(diamondBorder2);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(2, 1));
    contentPane.add(diamondButton);/*from  www  .java2  s .  c o  m*/
    contentPane.add(diamondButton2);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextPane c1 = new JTextPane();
    JTextPane c2 = new JTextPane();

    StyleContext styleContext = new StyleContext();
    c1.setDocument(new DefaultStyledDocument(styleContext));
    c2.setDocument(new DefaultStyledDocument(styleContext));

    Style style = c1.addStyle("style name", null);
    StyleConstants.setForeground(style, Color.red);

    style = c2.getStyle("style name");
    StyleConstants.setBold(style, true);
}

From source file:ABevelBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Bevel Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border raisedBorder = BorderFactory.createRaisedBevelBorder();
    Border loweredBorder = BorderFactory.createLoweredBevelBorder();
    Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.pink, Color.red);
    Border myLoweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.pink, Color.red);
    JButton raisedButton = new JButton("Raised");
    raisedButton.setBorder(raisedBorder);
    JButton loweredButton = new JButton("Lowered");
    loweredButton.setBorder(loweredBorder);
    JButton myRaisedButton = new JButton("My Raised");
    myRaisedButton.setBorder(myRaisedBorder);
    JButton myLoweredButton = new JButton("My Lowered");
    myLoweredButton.setBorder(myLoweredBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(2, 2, 5, 5));
    contentPane.add(raisedButton);/* ww w  .j  av  a2 s .c om*/
    contentPane.add(loweredButton);
    contentPane.add(myRaisedButton);
    contentPane.add(myLoweredButton);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:GStatePDF.java

public static void main(String[] args) {
    Document document = new Document();

    try {//from  w w  w  . ja  v  a 2s. c  o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("GStatePDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();
        PdfGState gs = new PdfGState();
        gs.setFillOpacity(0.5f);
        cb.setGState(gs);

        cb.setColorFill(Color.red);
        cb.circle(360.0f, 500.0f, 250.0f);
        cb.fill();
        gs.setFillOpacity(0.2f);
        cb.setGState(gs);
        cb.setColorFill(Color.blue);
        cb.circle(460.0f, 500.0f, 100.0f);
        cb.fill();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Oval Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setLayout(new GridLayout(2, 2));

    Color colors[] = { Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW };
    for (int i = 0; i < 4; i++) {
        MainClass panel = new MainClass(colors[i]);
        frame.add(panel);/*from   w ww .j av  a 2  s .c o m*/
    }

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(800, 600);//from ww  w . j av  a 2s. c  o  m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setBackground(Color.RED);
    frame.getContentPane().add(new Main());
    frame.setVisible(true);
}

From source file:ShadingPatternPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//from   w  w  w. j  a  v a  2  s  .  co m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ShadingPatternPDF.pdf"));
        document.open();

        PdfShading shading = PdfShading.simpleAxial(writer, 100, 100, 400, 100, Color.red, Color.cyan);
        PdfShadingPattern shadingPattern = new PdfShadingPattern(shading);

        PdfContentByte cb = writer.getDirectContent();

        cb.setShadingFill(shadingPattern);
        cb.circle(50, 50, 50);
        cb.stroke();

        PdfShading shadingR = PdfShading.simpleRadial(writer, 200, 500, 50, 300, 500, 100,
                new Color(255, 247, 148), new Color(247, 138, 107), false, false);
        cb.paintShading(shadingR);

        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jtp.setPreferredSize(new Dimension(400, 200));
    createTab("Reds", Color.RED);
    f.add(jtp, BorderLayout.CENTER);
    f.pack();/*  ww w  .  ja  v a2s  .c  o  m*/
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document.compress = false;/*w w w  . java  2s . c  o m*/
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    cb.circle(26.0f, 50.0f, 25.0f);
    cb.fill();
    cb.saveState();
    cb.setColorFill(Color.yellow);
    cb.circle(26.0f, 50.0f, 20.0f);
    cb.fill();
    cb.saveState();
    cb.setColorFill(Color.red);
    cb.circle(26.0f, 50.0f, 15.0f);
    cb.fill();
    cb.restoreState();
    cb.circle(26.0f, 50.0f, 10.0f);
    cb.fill();
    cb.restoreState();
    cb.circle(26.0f, 50.0f, 5.0f);
    cb.fill();
    document.close();
}