Example usage for java.awt Color BLACK

List of usage examples for java.awt Color BLACK

Introduction

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

Prototype

Color BLACK

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

Click Source Link

Document

The color black.

Usage

From source file:Main.java

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

    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);/*from ww  w  .  j a va2s  .com*/
    g2.setStroke(stroke);

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

From source file:Main.java

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

    Stroke stroke = new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);//from  w  w  w .  j  av  a  2s  .  com
    g2.setStroke(stroke);

    g2.setPaint(Color.black);
    g2.draw(new Rectangle2D.Float(10, 10, 200, 200));
}

From source file:org.jfree.chart.demo.ScatterPlotDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    xyplot.setDomainZeroBaselineVisible(true);
    xyplot.setRangeZeroBaselineVisible(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black);
    xylineandshaperenderer.setUseOutlinePaint(true);
    NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setTickMarkInsideLength(2.0F);
    numberaxis.setTickMarkOutsideLength(0.0F);
    NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis();
    numberaxis1.setTickMarkInsideLength(2.0F);
    numberaxis1.setTickMarkOutsideLength(0.0F);
    return jfreechart;
}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.red, Color.black));

    add(labelTwo);/* w w w .  j a  v a 2s .c  om*/

    JLabel labelThree = new JLabel("MatteBorder");
    labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
    add(labelThree);

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink),
                    "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM));
    add(labelFour);

    JLabel labelSix = new JLabel("CompoundBorder");
    Border one = BorderFactory.createEtchedBorder();
    Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
    labelSix.setBorder(BorderFactory.createCompoundBorder(one, two));
    add(labelSix);

}

From source file:Main.java

/**
 * Set the button to have simplified UI.
 * /*w  w w  .  j  ava2 s. c  om*/
 * @param button
 *            button to be modified
 * @param <T>
 *            type of button
 * @return button
 */
public static <T extends AbstractButton> T decoratedToSimpleButton(final T button) {

    button.setForeground(Color.BLACK);
    button.setBackground(Color.LIGHT_GRAY);
    button.setBorderPainted(true);
    button.setFocusPainted(true);
    button.setContentAreaFilled(false);
    button.setOpaque(true);

    if (button instanceof JToggleButton) {
        ((JToggleButton) button).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (button.isSelected()) {
                    button.setBackground(Color.WHITE);
                }
            }
        });
    }
    button.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseEntered(MouseEvent e) {
            super.mouseEntered(e);
            button.setBackground(Color.WHITE);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            super.mouseExited(e);
            if (!button.isSelected()) {
                button.setBackground(Color.LIGHT_GRAY);
            }
        }
    });

    button.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (!button.isSelected()) {
                button.setBackground(Color.LIGHT_GRAY);
            }
        }
    });
    Border line = new LineBorder(Color.BLACK);
    Border margin = new EmptyBorder(5, 15, 5, 15);
    Border compound = new CompoundBorder(line, margin);
    button.setBorder(compound);
    return button;
}

From source file:MainClass.java

public static void pictureBackdrop(float x, float y, PdfContentByte cb, PdfWriter writer) {
    PdfShading axial = PdfShading.simpleAxial(writer, x, y, x + 200, y, Color.yellow, Color.red);
    PdfShadingPattern axialPattern = new PdfShadingPattern(axial);
    cb.setShadingFill(axialPattern);/*ww w .ja  v a  2  s.com*/
    cb.setColorStroke(Color.black);
    cb.setLineWidth(2);
    cb.rectangle(x, y, 200, 200);
    cb.fillStroke();
}

From source file:Main.java

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

    JLabel lineBorderLabel = new JLabel("Line Border", JLabel.CENTER);
    lineBorderLabel.setBorder(BorderFactory.createLineBorder(Color.black));
    simplePanel.add(lineBorderLabel);//from   w ww.  j  ava2  s .c om

    add(simplePanel);
}

From source file:ColorBlocks.java

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

    Dimension d = getSize();/*from   w  ww  . j  a v a2s. c o  m*/
    g2.translate(d.width / 2, d.height / 2);

    Color[] colors = { Color.white, Color.lightGray, Color.gray, Color.darkGray, Color.black, Color.red,
            Color.pink, Color.orange, Color.yellow, Color.green, Color.magenta, Color.cyan, Color.blue };

    float size = 25;
    float x = -size * colors.length / 2;
    float y = -size * 3 / 2;

    // Show all the predefined colors.
    for (int i = 0; i < colors.length; i++) {
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(colors[i]);
        g2.fill(r);
    }

    //a linear gradient.
    y += size;
    Color c1 = Color.yellow;
    Color c2 = Color.blue;
    for (int i = 0; i < colors.length; i++) {
        float ratio = (float) i / (float) colors.length;
        int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
        int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
        int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
        Color c = new Color(red, green, blue);
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(c);
        g2.fill(r);
    }

    // Show an alpha gradient.
    y += size;
    c1 = Color.red;
    for (int i = 0; i < colors.length; i++) {
        int alpha = (int) (255 * (float) i / (float) colors.length);
        Color c = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), alpha);
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(c);
        g2.fill(r);
    }

    // Draw a frame around the whole thing.
    y -= size * 2;
    Rectangle2D frame = new Rectangle2D.Float(x, y, size * colors.length, size * 3);
    g2.setPaint(Color.black);
    g2.draw(frame);
}

From source file:Main.java

public int print(Graphics g, PageFormat Pf, int pageIndex) throws PrinterException {
    if (pageIndex > 0)
        return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) g;
    g2.setFont(sFont);// ww w  .jav a2 s  .co  m
    g2.setPaint(Color.black);
    g2.drawString("Save a tree!", 96, 144);
    return PAGE_EXISTS;
}

From source file:Main.java

public TestPane() {
    setBackground(Color.BLACK);
}