Example usage for java.awt Color green

List of usage examples for java.awt Color green

Introduction

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

Prototype

Color green

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

Click Source Link

Document

The color green.

Usage

From source file:TextPaneElements.java

public static void createDocumentStyles(StyleContext sc) {
    Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);

    // Create and add the main document style
    Style mainStyle = sc.addStyle(mainStyleName, defaultStyle);
    StyleConstants.setLeftIndent(mainStyle, 16);
    StyleConstants.setRightIndent(mainStyle, 16);
    StyleConstants.setFirstLineIndent(mainStyle, 16);
    StyleConstants.setFontFamily(mainStyle, "serif");
    StyleConstants.setFontSize(mainStyle, 12);

    // Create and add the constant width style
    Style cwStyle = sc.addStyle(charStyleName, null);
    StyleConstants.setFontFamily(cwStyle, "monospaced");
    StyleConstants.setForeground(cwStyle, Color.green);

    // Create and add the heading style
    Style heading2Style = sc.addStyle(heading2StyleName, null);
    StyleConstants.setForeground(heading2Style, Color.red);
    StyleConstants.setFontSize(heading2Style, 16);
    StyleConstants.setFontFamily(heading2Style, "serif");
    StyleConstants.setBold(heading2Style, true);
    StyleConstants.setLeftIndent(heading2Style, 8);
    StyleConstants.setFirstLineIndent(heading2Style, 0);

    // Create and add the Component style
    Class thisClass = TextPaneElements.class;
    URL url = thisClass.getResource("java2s.gif");
    ImageIcon icon = new ImageIcon(url);
    JLabel comp = new JLabel("Displaying text with attributes", icon, JLabel.CENTER);
    comp.setVerticalTextPosition(JLabel.BOTTOM);
    comp.setHorizontalTextPosition(JLabel.CENTER);
    comp.setFont(new Font("serif", Font.BOLD | Font.ITALIC, 14));
    Style componentStyle = sc.addStyle(componentStyleName, null);
    StyleConstants.setComponent(componentStyle, comp);

    // The paragraph style for the component
    Style compParagraphStyle = sc.addStyle(compParaName, null);
    StyleConstants.setSpaceAbove(compParagraphStyle, (float) 16.0);
}

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

private static void drawClipTest(Graphics2D g2) {
    g2.translate(10, 20);//from  w  w  w  .  ja  v  a  2 s  . com
    g2.setColor(Color.RED);
    g2.fillRect(10, 10, 100, 100);
    g2.clip(new Rectangle(0, 0, 60, 60));
    g2.setPaint(Color.BLUE);
    g2.fillRect(10, 10, 100, 100);
    g2.setClip(null);
    g2.setPaint(Color.GREEN);
    g2.fillRect(60, 60, 50, 50);
}

From source file:ImageProc.java

public static void imwrite(File file, int[][] classificationMat, int imgDim1, int imgDim2) {
    BufferedImage image = new BufferedImage(imgDim2, imgDim1, BufferedImage.TYPE_INT_RGB);

    for (int i = 0; i < imgDim1; i++) {
        for (int j = 0; j < imgDim2; j++) {

            switch (classificationMat[i][j]) {
            case 1:
                image.setRGB(j, i, Color.BLUE.getRGB());
                break;
            case 2:
                image.setRGB(j, i, Color.CYAN.getRGB());
                break;
            case 3:
                image.setRGB(j, i, Color.GREEN.getRGB());
                break;
            case 4:
                image.setRGB(j, i, Color.ORANGE.getRGB());
                break;
            case 5:
                image.setRGB(j, i, Color.RED.getRGB());
                break;
            }// www  .  ja  va2  s. c o  m
        }
    }
    try {
        ImageIO.write(image, "png", file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:GradientsLine.java

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

    GradientPaint gp1 = new GradientPaint(5, 25, Color.green, 2, 2, Color.black, true);

    g2d.setPaint(gp1);/* w  w  w  . j ava 2  s.c  o m*/
    g2d.fillRect(20, 140, 300, 40);

}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Some label text");
    label.setBorder(BorderFactory.createLineBorder(Color.green));
    label.setFont(new Font("Serif", Font.ITALIC, 16));

    getContentPane().add(label);//from w  w w  .ja v a 2  s.c  o m
    pack();
    setVisible(true);
}

From source file:Main.java

public Main() {
    Object[] items = { Color.red, Color.green, Color.blue };
    JComboBox comboBox = new JComboBox(items);
    comboBox.setRenderer(new ColorRenderer(comboBox));
    getContentPane().add(comboBox, BorderLayout.NORTH);
    add(new JTextField(), BorderLayout.SOUTH);
}

From source file:XORPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.red);/*from w w  w . j  ava  2s .  c  o  m*/
    g.fillRect(10, 10, 80, 30);
    g.setColor(Color.green);
    g.fillRect(50, 20, 80, 30);
    g.setColor(Color.blue);
    g.fillRect(130, 40, 80, 30);
    g.setXORMode(Color.green);
    g.fillRect(90, 30, 80, 30);
}

From source file:Shear.java

public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2d = (Graphics2D) g;

    AffineTransform tx1 = new AffineTransform();
    tx1.translate(50, 90);//from w w w. j av a2 s . c om

    g2d.setTransform(tx1);
    g2d.setColor(Color.green);
    g2d.drawRect(0, 0, 80, 50);

    AffineTransform tx2 = new AffineTransform();
    tx2.translate(50, 90);
    tx2.shear(0, 1);

    g2d.setTransform(tx2);
    g2d.setColor(Color.blue);

    g2d.draw(new Rectangle(0, 0, 80, 50));

}

From source file:CompoundBorderLineLineBorder.java

public CompoundBorderLineLineBorder() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    JLabel label;/*from w  w  w .  ja va  2  s .  c o m*/

    label = new JLabel("Compound - red inside green lines");
    label.setBorder(BorderFactory.createCompoundBorder(new LineBorder(Color.green), new LineBorder(Color.red)));
    panel.add(label);
    getContentPane().add(panel);
    pack();
}

From source file:MyCanvas.java

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

    //Draw the open arc 
    Arc2D.Float arc = new Arc2D.Float(Arc2D.OPEN);
    arc.setFrame(140, 100, 67, 46);/*w ww  . j  a  va 2  s .  c om*/
    arc.setAngleStart(45);
    arc.setAngleExtent(270);
    g2.setColor(Color.gray);
    g2.draw(arc);
    g2.setColor(Color.green);
    g2.fill(arc);
    g2.setColor(Color.black);
    g2.drawString("Arc2D.OPEN", 140, 90);
}