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

@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    Component c = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (c instanceof JLabel) {
        if (isSelected) {
            c.setBackground(Color.blue);
        } else {/*from  w  ww  .j  av  a 2s .  co m*/
            c.setBackground(Color.red);
        }
    } else {
        c.setBackground(Color.red);
        c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    }
    return c;
}

From source file:Main.java

public void drawImage() {
    Graphics2D g = img.createGraphics();
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHints(hints);//from   w  ww .  ja  va  2 s .  c o m

    g.setStroke(new BasicStroke(4));
    for (Ellipse2D shape : shapes) {
        g.setColor(Color.blue);
        g.fill(shape);
        if (shape.contains(mouse)) {
            g.setColor(Color.RED);
        } else {
            g.setColor(Color.YELLOW);
        }
        g.draw(shape);
    }

    l.setIcon(new ImageIcon(img));

    g.dispose();
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g.create();
    if (myImage != null) {
        int x = (getWidth() - myImage.getWidth()) / 2;
        int y = (getHeight() - myImage.getHeight()) / 2;
        g2d.drawImage(myImage, x, y, this);

        g2d.setColor(Color.RED);
        g2d.translate(x, y);//ww  w. ja v  a2  s  .c  o m
        g2d.draw(myOffice);
    }
    g2d.dispose();
}

From source file:edu.jhuapl.graphs.jfreechart.PieEffectsTest.java

public static JFreeChartGraphSource getSource() throws GraphException {
    Map<String, Object> emptyMap = Collections.emptyMap();

    List<PointInterface> ps1 = new LinkedList<PointInterface>();

    Map<String, Object> params = new HashMap<String, Object>(1);
    params.put(GraphSource.ITEM_COLOR, Color.red);
    ps1.add(new DataPoint(3, "Red", params));

    params = new HashMap<String, Object>(1);
    params.put(GraphSource.ITEM_COLOR, Color.green);
    ps1.add(new DataPoint(5, "Green", params));

    params = new HashMap<String, Object>(1);
    params.put(GraphSource.ITEM_COLOR, Color.blue);
    ps1.add(new DataPoint(7, "Blue", params));

    DataSeries s1 = new DataSeries(ps1, emptyMap);

    Map<String, Object> graphParams = new HashMap<String, Object>();
    graphParams.put(GraphSource.GRAPH_TYPE, GraphSource.GRAPH_TYPE_PIE);
    graphParams.put(GraphSource.GRAPH_LEGEND, true);

    JFreeChartGraphSource source = new JFreeChartGraphSource();
    source.setData(Arrays.asList(s1));
    source.setParams(graphParams);//from  w ww.  ja v  a 2s  .c o m
    source.initialize();

    return source;
}

From source file:FontShow.java

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

    Font font = new Font("Dialog", Font.PLAIN, 96);
    g2.setFont(font);/*from w w w.java 2  s. com*/
    int width = getSize().width;
    int height = getSize().height;

    String message = "Java2s";

    FontRenderContext frc = g2.getFontRenderContext();
    LineMetrics metrics = font.getLineMetrics(message, frc);
    float messageWidth = (float) font.getStringBounds(message, frc).getWidth();

    // center text
    float ascent = metrics.getAscent();
    float descent = metrics.getDescent();
    float x = (width - messageWidth) / 2;
    float y = (height + metrics.getHeight()) / 2 - descent;

    int PAD = 25;
    g2.setPaint(getBackground());
    g2.fillRect(0, 0, width, height);

    g2.setPaint(getForeground());
    g2.drawString(message, x, y);

    g2.setPaint(Color.white); // Base lines
    drawLine(g2, x - PAD, y, x + messageWidth + PAD, y);
    drawLine(g2, x, y + PAD, x, y - ascent - PAD);
    g2.setPaint(Color.green); // Ascent line
    drawLine(g2, x - PAD, y - ascent, x + messageWidth + PAD, y - ascent);
    g2.setPaint(Color.red); // Descent line
    drawLine(g2, x - PAD, y + descent, x + messageWidth + PAD, y + descent);
}

From source file:com.mgmtp.perfload.loadprofiles.ui.component.StringCellEditor.java

@Override
public boolean stopCellEditing() {
    String s = (String) super.getCellEditorValue();
    if (isBlank(s)) {
        editorComponent.setBorder(new LineBorder(Color.red));
        return false;
    }//  ww  w  .j  a  va  2 s. c o m

    int row = table.getSelectedRow();

    for (int i = 0; i < objects.size(); ++i) {
        if (i != row && s.equals(objects.get(i).getName())) {
            editorComponent.setBorder(new LineBorder(Color.red));
            return false;
        }
    }

    return super.stopCellEditing();
}

From source file:ColorMenu.java

public ColorMenu(String name) {
    super(name);/*w  w  w.  ja v a 2s .  com*/

    _unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()),
            new BevelBorder(BevelBorder.LOWERED, Color.WHITE, Color.GRAY));

    _selectedBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.RED),
            new MatteBorder(1, 1, 1, 1, getBackground()));

    _activeBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.BLUE),
            new MatteBorder(1, 1, 1, 1, getBackground()));

    JPanel p = new JPanel();
    p.setBorder(new EmptyBorder(5, 5, 5, 5));
    p.setLayout(new GridLayout(8, 8));
    _colorPanes = new HashMap();

    int values[] = new int[] { 0, 128, 192, 255 };

    for (int r = 0; r < values.length; r++)
        for (int g = 0; g < values.length; g++)
            for (int b = 0; b < values.length; b++) {
                Color color = new Color(values[r], values[g], values[b]);
                ColorPane colorPane = new ColorPane(color);
                p.add(colorPane);
                _colorPanes.put(color, colorPane);
            }

    add(p);

}

From source file:MainClass.java

public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
    System.out.println("Page index = " + pageIndex);
    // pageIndex 1 corresponds to page number 2.
    if (pageIndex > 2)
        return Printable.NO_SUCH_PAGE;

    Graphics2D g2 = (Graphics2D) g;

    double w = pf.getImageableWidth();
    double h = pf.getImageableHeight();

    int xo = (int) pf.getImageableX();
    int yo = (int) pf.getImageableY();

    Rectangle2D r = new Rectangle2D.Double(xo, yo, w, h);

    g2.setColor(Color.red);
    g2.draw(r);/*from   ww  w.  j ava  2  s.  com*/

    return Printable.PAGE_EXISTS;
}

From source file:com.googlecode.commons.swing.component.FormNotifier.java

public FormNotifier() {
    super();
    setIcon(iconError);
    setBorder(borderError);
    setBackground(Color.RED);
    setVerticalTextPosition(JLabel.TOP);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);//from   w  ww.  jav  a  2  s  .  c o  m
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}