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

public void mouseExited(MouseEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.setBackground(Color.red);
    c.repaint();
}

From source file:userinterface.patientRole.LineChart.java

public LineChart(String applicationTitle, String chartTitle, XYSeries bR, XYSeries pR, XYSeries bS, XYSeries bP,
        JFrame parent) {/*from   w  ww .  j ava  2s.  c  o  m*/
    // super(applicationTitle);
    this.bR = bR;
    this.pR = pR;
    this.bS = bS;
    this.bP = bP;
    this.parent = parent;
    dataset = createDataset();
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Vital Signs",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    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);
    setContentPane(chartPanel);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
}

From source file:com.anrisoftware.prefdialog.miscswing.validatingfields.ValidatingComponent.java

/**
 * Sets the component.//from  w  w  w  .  j a  va  2  s.  com
 *
 * @param component
 *            the {@link JComponent}.
 */
public ValidatingComponent(JComponent component, ToolTipShower toolTip) {
    this.component = component;
    this.toolTip = toolTip;
    this.valid = true;
    this.invalidBackground = Color.RED;
}

From source file:org.samjoey.graphing.GraphUtility.java

/**
 *
 * @param games the games to graph//from   w w w .  j a  v a 2  s .  c o  m
 * @param key the variable to create the graph with
 * @param start if index, the index at which to start, else the percent in
 * the game at which to start
 * @param stop if index, the index at which to end, else the percent in the
 * game at which to end
 * @param index
 * @return
 */
public static ChartPanel getCustomGraph(Game[] games, String key, double start, double stop, boolean index) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    for (Game game : games) {
        ArrayList<Double> data = game.getVar(key);
        int begin;
        int end;
        if (index) {
            begin = (int) start;
            end = (int) stop;
        } else {
            begin = (int) (data.size() / start);
            end = (int) (data.size() / stop);
        }
        XYSeries series = GraphUtility.createSeries(data.subList(begin, end), "" + game.getId());
        dataset.addSeries(series);
    }
    JFreeChart chart = ChartFactory.createXYLineChart(key, // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer rend = plot.getRenderer();
    for (int i = 0; i < games.length; i++) {
        Game g = games[i];
        if (g.getWinner() == 1) {
            rend.setSeriesPaint(i, Color.RED);
        }
        if (g.getWinner() == 2) {
            rend.setSeriesPaint(i, Color.BLACK);
        }
        if (g.getWinner() == 0) {
            rend.setSeriesPaint(i, Color.PINK);
        }
    }
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}

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

@Override
public boolean stopCellEditing() {
    String s = (String) super.getCellEditorValue();
    JTextField textField = (JTextField) getComponent();

    if (isBlank(s)) {
        textField.setBorder(new LineBorder(Color.red));
        return false;
    }/*from w  w  w.j  a  va2 s.  c  o m*/

    try {
        value = Double.valueOf(s);
    } catch (NumberFormatException ex2) {
        try {
            Number n = FORMAT.parse(s);
            value = n.doubleValue();
        } catch (ParseException ex1) {
            textField.setBorder(new LineBorder(Color.red));
            textField.selectAll();
            return false;
        }
    }

    return super.stopCellEditing();
}

From source file:com.sciaps.utils.Util.java

public static int validateZeroOrGreater(JTextField txtField) {

    Pattern pattern = Pattern.compile(POSITIVE_INT);
    if (pattern.matcher(txtField.getText()).matches()) {
        txtField.setBackground(Color.white);
        return getStringToInt(txtField.getText());
    }/*from   ww  w  .j  a  v  a 2s .  com*/

    txtField.setBackground(Color.red);
    return -1;
}

From source file:Main.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    CheckComboStore store = (CheckComboStore) value;
    checkBox.setText(store.id);//w w w . j  a  va  2s . c  o  m
    checkBox.setSelected(((Boolean) store.state).booleanValue());
    checkBox.setBackground(isSelected ? Color.red : Color.white);
    checkBox.setForeground(isSelected ? Color.white : Color.black);
    return checkBox;
}

From source file:ImageProcessing.RGBHistogram_GUI.java

public RGBHistogram_GUI(Component callerComponent) {
    //callerComponent is used only to determine the position of this
    //frame when called.
    initComponents();/*from   w ww . ja v a 2 s.com*/
    this.setLocationRelativeTo(callerComponent);

    //Determine the chart width & height for displaying.
    int chartLabelHeight = sourceImageGreenHistogram.getHeight();
    int chartLabelWidth = sourceImageGreenHistogram.getWidth();

    //Get values for each color component from source image.
    double[] sourceRedValues = ImageProcessing.extractRedColor(Main.getSourceImage());
    double[] sourceGreenValues = ImageProcessing.extractGreenColor(Main.getSourceImage());
    double[] sourceBlueValues = ImageProcessing.extractBlueColor(Main.getSourceImage());

    //Get values for each color component from processed image.
    double[] processedRedValues = ImageProcessing.extractRedColor(Main.getProcessedImage());
    double[] processedGreenValues = ImageProcessing.extractGreenColor(Main.getProcessedImage());
    double[] processedBlueValues = ImageProcessing.extractBlueColor(Main.getProcessedImage());

    //Create charts for each color component from source image.
    JFreeChart sourceRedChart = ImageProcessing.createHistogram(sourceRedValues, Color.RED);
    JFreeChart sourceGreenChart = ImageProcessing.createHistogram(sourceGreenValues, Color.GREEN);
    JFreeChart sourceBlueChart = ImageProcessing.createHistogram(sourceBlueValues, Color.BLUE);

    //Create charts for each color component from processed image.
    JFreeChart processedRedChart = ImageProcessing.createHistogram(processedRedValues, Color.RED);
    JFreeChart processedGreenChart = ImageProcessing.createHistogram(processedGreenValues, Color.GREEN);
    JFreeChart processedBlueChart = ImageProcessing.createHistogram(processedBlueValues, Color.BLUE);

    //Convert each source image charts to a BufferedImage.
    BufferedImage sourceRedChartImage = sourceRedChart.createBufferedImage(chartLabelWidth, chartLabelHeight);
    BufferedImage sourceGreenChartImage = sourceGreenChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage sourceBlueChartImage = sourceBlueChart.createBufferedImage(chartLabelWidth, chartLabelHeight);

    //Convert each processsed image charts to a BufferedImage.
    BufferedImage processedRedChartImage = processedRedChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage processedGreenChartImage = processedGreenChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage processedBlueChartImage = processedBlueChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);

    //Display each source image charts to GUI.
    sourceImageRedHistogram.setIcon(new ImageIcon(sourceRedChartImage));
    sourceImageGreenHistogram.setIcon(new ImageIcon(sourceGreenChartImage));
    sourceImageBlueHistogram.setIcon(new ImageIcon(sourceBlueChartImage));

    //Display each source image charts to GUI.
    processedImageRedHistogram.setIcon(new ImageIcon(processedRedChartImage));
    processedImageGreenHistogram.setIcon(new ImageIcon(processedGreenChartImage));
    processedImageBlueHistogram.setIcon(new ImageIcon(processedBlueChartImage));

}

From source file:TextureWithBufferedImage.java

public void paint(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    Rectangle2D rec1, rec2, rec3, rec4, rec5;
    rec1 = new Rectangle2D.Float(25, 25, 75, 150);
    rec2 = new Rectangle2D.Float(125, 25, 10, 75);
    rec3 = new Rectangle2D.Float(75, 125, 125, 75);
    rec4 = new Rectangle2D.Float(25, 15, 12, 75);
    rec5 = new Rectangle2D.Float(15, 50, 15, 15);

    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1);
    g2D.setComposite(ac);/*from w w w.j  a v  a  2  s . c o m*/

    g2D.setStroke(new BasicStroke(5.0f));
    g2D.draw(rec1);
    GradientPaint gp = new GradientPaint(125f, 25f, Color.yellow, 225f, 100f, Color.blue);
    g2D.setPaint(gp);
    g2D.fill(rec2);
    BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
    Graphics2D big = bi.createGraphics();
    big.setColor(Color.magenta);
    big.fillRect(0, 0, 5, 5);
    big.setColor(Color.black);
    big.drawLine(0, 0, 5, 5);
    Rectangle r = new Rectangle(0, 0, 5, 5);
    TexturePaint tp = new TexturePaint(bi, r);

    g2D.setPaint(tp);
    g2D.fill(rec3);
    g2D.setColor(Color.green);
    g2D.fill(rec4);
    g2D.setColor(Color.red);
    g2D.fill(rec5);
}

From source file:com.mycompany.istudy.principalservices.GraphicalView.java

/**
 * Overwrites the method of createXYLineChart from ChartFactory interface
 * and creates a XYLine Chart./*from   ww w.j a va 2 s.  c  o m*/
 * @param applicationTitle
 * @param chartTitle
 * @param investedHoursPerWeek
 * @param hoursToBeInvested 
 */
public GraphicalView(String applicationTitle, String chartTitle, Map<Double, Double> investedHoursPerWeek,
        Map<Double, Double> hoursToBeInvested) {
    super(applicationTitle);
    xylineChart = ChartFactory.createXYLineChart(chartTitle, "Calender Weeks", "Invested Study-hours",
            createDataset(investedHoursPerWeek, hoursToBeInvested), 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.BLUE);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);
}