Example usage for java.awt Color blue

List of usage examples for java.awt Color blue

Introduction

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

Prototype

Color blue

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

Click Source Link

Document

The color blue.

Usage

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from  w  w w.  jav a 2  s.c o  m*/
    PdfContentByte cb = writer.getDirectContent();

    PdfPatternPainter circle = cb.createPattern(15, 15, 10, 20, Color.blue);
    circle.circle(7.5f, 7.5f, 2.5f);
    circle.fill();

    PatternColor circles = new PatternColor(circle);

    cb.setColorFill(circles);
    cb.rectangle(252, 716, 72, 72);
    cb.fillStroke();

    document.close();
}

From source file:MainClass.java

public static void main(String argv[]) {

    ColorPane pane = new ColorPane();
    for (int n = 1; n <= 400; n += 1) {
        if (isPrime(n)) {
            pane.append(Color.red, String.valueOf(n) + ' ');
        } else if (isPerfectSquare(n)) {
            pane.append(Color.blue, String.valueOf(n) + ' ');
        } else {/*from w w  w. j  a  va  2 s.  co m*/
            pane.append(Color.black, String.valueOf(n) + ' ');
        }
    }

    JFrame f = new JFrame("ColorPane example");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new JScrollPane(pane));
    f.setSize(600, 400);
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();//from  www. ja  v  a2  s . com
    PdfContentByte cb = writer.getDirectContent();
    PdfShading axial = PdfShading.simpleAxial(writer, 36, 716, 396, 788, Color.orange, Color.blue);

    PdfShadingPattern axialPattern = new PdfShadingPattern(axial);
    ShadingColor axialColor = new ShadingColor(axialPattern);
    cb.setColorFill(axialColor);
    cb.rectangle(36, 608, 72, 72);
    cb.rectangle(144, 608, 72, 72);
    cb.rectangle(252, 608, 72, 72);
    cb.rectangle(360, 608, 72, 72);
    cb.fillStroke();
    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);//www  .  j a  va2 s  .c o  m
    }

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

From source file:Main.java

public static void main(String args[]) {
    JTextArea textArea = new JTextArea();

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    DefaultCaret caret = new DefaultCaret() {
        @Override/*  w w  w.ja va 2  s.  co m*/
        public boolean isSelectionVisible() {
            return true;
        }
    };
    textArea.setCaret(caret);
    textArea.setFont(new java.awt.Font("Miriam Fixed", 0, 13));

    Color color = Color.BLUE;
    // textArea.setBackground(color);
    textArea.setSelectedTextColor(color);
    f.getContentPane().add(new JScrollPane(textArea));
    f.pack();
    f.setVisible(true);
}

From source file:OvalPanel.java

License:asdf

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++) {
        OvalPanel panel = new OvalPanel(colors[i]);
        panel.add(new JButton("asdf"));
        frame.add(panel);//from  w  w  w .j  av a2s .  c o  m
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    final int STRING_POSITION = 1;
    Object buttonColors[][] = { { Color.RED, "RED" }, { Color.BLUE, "BLUE" }, { Color.GREEN, "GREEN" },
            { Color.BLACK, "BLACK" }, null, // separator
            { Color.CYAN, "CYAN" } };

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ActionListener actionListener = new TheActionListener();

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);// w  w  w  .  ja  va 2s  .c o  m

    for (Object[] color : buttonColors) {
        if (color == null) {
            toolbar.addSeparator();
        } else {
            Icon icon = MetalIconFactory.getTreeComputerIcon();
            JButton button = new JButton(icon);
            button.setActionCommand((String) color[STRING_POSITION]);
            button.addActionListener(actionListener);
            toolbar.add(button);
        }
    }

    Action action = new ShowAction(toolbar);
    JButton button = new JButton(action);
    toolbar.add(button);

    Container contentPane = frame.getContentPane();
    contentPane.add(toolbar, BorderLayout.NORTH);
    JTextArea textArea = new JTextArea();
    JScrollPane pane = new JScrollPane(textArea);
    contentPane.add(pane, BorderLayout.CENTER);
    frame.setSize(350, 150);
    frame.setVisible(true);

}

From source file:GStatePDF.java

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

    try {/*ww  w .ja  v  a 2 s  .  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("Changed Renderer");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();

    renderer.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 32));
    int rowHeight = tree.getRowHeight();
    if (rowHeight <= 0) {
        tree.setRowHeight(rowHeight - 1);
    }/*  w  ww.jav a2 s  .  com*/

    Color backgroundSelection = renderer.getBackgroundSelectionColor();
    renderer.setBackgroundSelectionColor(Color.blue);
    renderer.setBackgroundNonSelectionColor(backgroundSelection);

    // Swap text colors
    Color textSelection = renderer.getTextSelectionColor();
    renderer.setTextSelectionColor(Color.green);
    renderer.setTextNonSelectionColor(textSelection);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:ComplexRenderingSample.java

public static void main(String args[]) {

    Object elements[][] = {/*  ww w . j a va 2s.  c  o m*/
            { new Font("Helvetica", Font.PLAIN, 20), Color.red, new DiamondIcon(Color.blue), "Help" },
            { new Font("TimesRoman", Font.BOLD, 14), Color.blue, new DiamondIcon(Color.green), "Me" },
            { new Font("Courier", Font.ITALIC, 18), Color.green, new DiamondIcon(Color.black), "I'm" },
            { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.gray, new DiamondIcon(Color.magenta),
                    "Trapped" },
            { new Font("TimesRoman", Font.PLAIN, 32), Color.pink, new DiamondIcon(Color.yellow), "Inside" },
            { new Font("Courier", Font.BOLD, 16), Color.yellow, new DiamondIcon(Color.red), "This" },
            { new Font("Helvetica", Font.ITALIC, 8), Color.darkGray, new DiamondIcon(Color.pink),
                    "Computer" } };

    JFrame frame = new JFrame("Complex Renderer");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    JList jlist = new JList(elements);
    ListCellRenderer renderer = new ComplexCellRenderer();
    jlist.setCellRenderer(renderer);
    JScrollPane scrollPane = new JScrollPane(jlist);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    JComboBox comboBox = new JComboBox(elements);
    comboBox.setRenderer(renderer);
    contentPane.add(comboBox, BorderLayout.NORTH);

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