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

public ActionDisabled() {
    this.setJMenuBar(menuBar);
    menuBar.add(testMenu);//from  ww  w .  jav  a  2s  .c o m

    testMenu.add(theAction);
    toolBar.add(theAction);

    disableActionItem.setActionCommand(DISABLE);
    testMenu.add(disableActionItem);
    disableActionItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(DISABLE)) {
                theAction.setEnabled(false);
                disableActionItem.setText("Enable the Action");
                disableActionItem.setActionCommand(ENABLE);
            } else {
                theAction.setEnabled(true);
                disableActionItem.setText("Disable the Action");
                disableActionItem.setActionCommand(DISABLE);
            }
        }
    });
    this.getContentPane().add(toolBar, BorderLayout.NORTH);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.getContentPane().setBackground(Color.red);
    this.setSize(320, 200);
    this.setVisible(true);
}

From source file:Main.java

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

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int cx = getSize().width / 2;
    int cy = getSize().height / 2;

    g2.translate(cx, cy);/*from ww w  .j a va2 s  . c  om*/
    g2.rotate(theta * Math.PI / 180);

    Shape oldClip = g2.getClip();
    Shape e = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2);
    g2.clip(e);

    Shape c = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2);
    g2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white, true));
    g2.fill(c);

    g2.setPaint(Color.yellow);
    g2.fillOval(cx / 4, 0, cx, cy);

    g2.setClip(oldClip);

    g2.setFont(new Font("Times New Roman", Font.PLAIN, 64));
    g2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black, false));
    g2.drawString("Hello, 2D!", -cx * 3 / 4, cy / 4);

    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) .75);
    g2.setComposite(ac);

    Shape r = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4, 20, 20);
    g2.setStroke(new BasicStroke(4));
    g2.setPaint(Color.magenta);
    g2.fill(r);
    g2.setPaint(Color.green);
    g2.draw(r);

    g2.drawImage(image, -cx / 2, -cy / 2, this);
}

From source file:TreeNodeVector.java

public EmployeeCellRenderer() {
    firstNameLabel.setForeground(Color.BLUE);
    renderer.add(firstNameLabel);//from w w  w .j  a  va2s.c o  m

    lastNameLabel.setForeground(Color.BLUE);
    renderer.add(lastNameLabel);

    salaryLabel.setHorizontalAlignment(JLabel.RIGHT);
    salaryLabel.setForeground(Color.RED);
    renderer.add(salaryLabel);
    renderer.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    backgroundSelectionColor = defaultRenderer.getBackgroundSelectionColor();
    backgroundNonSelectionColor = defaultRenderer.getBackgroundNonSelectionColor();
}

From source file:Main.java

AnimatedImage() {
    super(60, 60, BufferedImage.TYPE_INT_RGB);
    frameGradient = new GradientPaint[6];
    for (int i = 0; i < frameGradient.length; i++) {
        frameGradient[i] = new GradientPaint(0f, (float) i, Color.BLUE, 0f, (float) i + 13, Color.RED, true);
    }/*from  w w w .  j  a va 2  s .  c  o m*/
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical1, double[] YDataNumerical2) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForThree(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2),
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f));
    plot.setRenderer(renderer);/*from www.j  a  v  a 2  s  .  c  o m*/
    setContentPane(chartPanel);

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}

From source file:grafix.graficos.indices.IndiceBollinger.java

@Override
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) {
    float[] color = getCor().getComponents(null);
    XYDifferenceRenderer r = new XYDifferenceRenderer(new Color(color[0], color[1], color[2], .1f), Color.red,
            false);/*from w ww. java 2 s  . c  om*/
    r.setStroke(new BasicStroke(.75f));
    r.setPaint(getCor());
    plot.setRenderer(contador, r);
    plot.setDataset(contador, getDataSet(janela));
}

From source file:MouseTest.java

public MouseTest() {
    super();//from ww w .j  a  va2  s .  c  o m

    final JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("Cut"));
    pop.add(new JMenuItem("Copy"));
    pop.add(new JMenuItem("Paste"));
    pop.addSeparator();
    pop.add(new JMenuItem("Select All"));
    pop.setInvoker(this);

    MouseListener popup = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        private void showPopup(MouseEvent e) {
            pop.show(e.getComponent(), e.getX(), e.getY());
        }
    };
    addMouseListener(popup);

    MouseListener drawing1 = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            color = Color.RED;
            startX = endX = e.getX();
            startY = endY = e.getY();
            repaint();
        }

        public void mouseReleased(MouseEvent e) {
            color = Color.BLACK;
            repaint();
        }
    };
    addMouseListener(drawing1);

    MouseMotionListener drawing2 = new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            endX = e.getX();
            endY = e.getY();
            repaint();
        }

        public void mouseMoved(MouseEvent e) {
        }
    };
    addMouseMotionListener(drawing2);

}

From source file:FormularioGuardarEstudio.java

private void clickGuardarEstudio(ActionEvent e) {

    if (!nombreEstudio.getText().toString().trim().isEmpty() && pacientesCombo.getSelectedItem() != null) {

        Estudio estudio = new Estudio(imagen, nombreEstudio.getText().toString().trim(),
                descripcion.getText().toString().trim(), notas.getText().toString().trim());
        guardarEstudioEnBase(estudio);//ww  w .ja  va 2s.  co  m
    } else {

        mostrarMensaje("Ingrese un nombre de estudio", Color.RED);
    }
}

From source file:finale.year.stage.main.Authentification.java

/**
 *
 * @param message//from   w  ww  . java2  s . com
 */
public static void updateStatus(final String message) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            try {
                errorStatusBar.setText("");
                errorStatusBar.setForeground(Color.red);
                errorStatusBar.setText(message);
            } catch (NullPointerException e) {
                return;
            }
        }

    });

}

From source file:D20140128.ApacheXMLGraphicsTest.EPSExample1.java

/**
 * Creates an EPS file. The contents are painted using a Graphics2D
 * implementation that generates an EPS file.
 *
 * @param outputFile the target file/*w  w w.  j a  v  a 2s  .  c om*/
 * @throws IOException In case of an I/O error
 */
public static void generateEPSusingJava2D(File outputFile) throws IOException {
    OutputStream out = new java.io.FileOutputStream(outputFile);
    out = new java.io.BufferedOutputStream(out);
    try {
        //Instantiate the EPSDocumentGraphics2D instance
        EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        //Set up the document size
        g2d.setupDocument(out, 400, 200); //400pt x 200pt

        //Paint a bounding box
        g2d.drawRect(0, 0, 400, 200);

        //A few rectangles rotated and with different color
        Graphics2D copy = (Graphics2D) g2d.create();
        int c = 12;
        for (int i = 0; i < c; i++) {
            float f = ((i + 1) / (float) c);
            Color col = new Color(0.0f, 1 - f, 0.0f);
            copy.setColor(col);
            copy.fillRect(70, 90, 50, 50);
            copy.rotate(-2 * Math.PI / (double) c, 70, 90);
        }
        copy.dispose();

        //Some text
        g2d.rotate(-0.25);
        g2d.setColor(Color.RED);
        g2d.setFont(new Font("sans-serif", Font.PLAIN, 36));
        g2d.drawString("Hello world!", 140, 140);
        g2d.setColor(Color.RED.darker());
        g2d.setFont(new Font("serif", Font.PLAIN, 36));
        g2d.drawString("Hello world!", 140, 180);

        //Cleanup
        g2d.finish();
    } finally {
        IOUtils.closeQuietly(out);
    }
}