Example usage for java.awt Color WHITE

List of usage examples for java.awt Color WHITE

Introduction

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

Prototype

Color WHITE

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

Click Source Link

Document

The color white.

Usage

From source file:MyCanvas.java

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

    // draw entire component white
    g.setColor(Color.white);
    g.fillRect(0, 0, getWidth(), getHeight());

    // yellow circle
    g.setColor(Color.yellow);//from  ww w .  j  ava  2s  . c  om
    g.fillOval(0, 0, 240, 240);

    // magenta circle
    g.setColor(Color.magenta);
    g.fillOval(160, 160, 240, 240);

    // paint the icon below blue sqaure
    int w = java2sLogo.getIconWidth();
    int h = java2sLogo.getIconHeight();
    java2sLogo.paintIcon(this, g, 280 - (w / 2), 120 - (h / 2));

    // paint the icon below red sqaure
    java2sLogo.paintIcon(this, g, 120 - (w / 2), 280 - (h / 2));

    // transparent red square
    g.setColor(m_tRed);
    g.fillRect(60, 220, 120, 120);

    // transparent green circle
    g.setColor(m_tGreen);
    g.fillOval(140, 140, 120, 120);

    // transparent blue square
    g.setColor(m_tBlue);
    g.fillRect(220, 60, 120, 120);

    g.setColor(Color.black);

    g.setFont(monoFont);
    FontMetrics fm = g.getFontMetrics();
    w = fm.stringWidth("Java Source");
    h = fm.getAscent();
    g.drawString("Java Source", 120 - (w / 2), 120 + (h / 4));

    g.setFont(sanSerifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("and");
    h = fm.getAscent();
    g.drawString("and", 200 - (w / 2), 200 + (h / 4));

    g.setFont(serifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("Support.");
    h = fm.getAscent();
    g.drawString("Support.", 280 - (w / 2), 280 + (h / 4));
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 1", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    CategoryMarker categorymarker = new CategoryMarker("Category 4", Color.blue, new BasicStroke(1.0F));
    categorymarker.setDrawAsLine(true);/*from  ww w  .j av  a2 s .  com*/
    categorymarker.setLabel("Marker Label");
    categorymarker.setLabelFont(new Font("Dialog", 0, 11));
    categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D));
    categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND);
    return jfreechart;
}

From source file:EvenOddRenderer.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);//from w w  w  .ja va 2 s  .  c om
    Color foreground, background;
    if (isSelected) {
        foreground = Color.YELLOW;
        background = Color.GREEN;
    } else {
        if (row % 2 == 0) {
            foreground = Color.BLUE;
            background = Color.WHITE;
        } else {
            foreground = Color.WHITE;
            background = Color.BLUE;
        }
    }
    renderer.setForeground(foreground);
    renderer.setBackground(background);
    return renderer;
}

From source file:Main.java

public Main() {
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(new JButton("Foo"));
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(new JButton("Bar"));

    String[] columnNames = { "Mon", "Tues", "Wed" };
    DefaultTableModel model = new DefaultTableModel(columnNames, 25);
    JTable table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setPreferredSize(table.getPreferredSize());

    JLabel southLabel = new JLabel("OK!");
    southLabel.setForeground(Color.white);
    JPanel southPanel = new JPanel();
    southPanel.add(southLabel);// w  w w  .  jav a  2 s  .com

    setLayout(new BorderLayout(5, 5));
    add(buttonPanel, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(southPanel, BorderLayout.SOUTH);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25),
            new BasicStroke(1.0F));
    categorymarker.setDrawAsLine(false);
    categorymarker.setAlpha(1.0F);/*  w  w  w  .j a v  a  2s .c o  m*/
    categorymarker.setLabel("Marker Label");
    categorymarker.setLabelFont(new Font("Dialog", 0, 11));
    categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D));
    categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND);
    return jfreechart;
}

From source file:QRCode.java

public static String createQRCode(String arg) {
    int size = 125;
    String fileType = "png";
    File myFile = null;/* w w  w . j  av  a  2  s . c o  m*/
    UUID uuid = UUID.nameUUIDFromBytes(arg.getBytes());

    try {
        myFile = File.createTempFile("temp-file-name", ".png");

        Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
        hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
        QRCodeWriter qrCodeWriter = new QRCodeWriter();
        BitMatrix byteMatrix = qrCodeWriter.encode(uuid.toString(), BarcodeFormat.QR_CODE, size, size, hintMap);
        int CrunchifyWidth = byteMatrix.getWidth();
        BufferedImage image = new BufferedImage(CrunchifyWidth, CrunchifyWidth, BufferedImage.TYPE_INT_RGB);
        image.createGraphics();

        Graphics2D graphics = (Graphics2D) image.getGraphics();
        graphics.setColor(Color.WHITE);
        graphics.fillRect(0, 0, CrunchifyWidth, CrunchifyWidth);
        graphics.setColor(Color.BLACK);

        for (int i = 0; i < CrunchifyWidth; i++) {
            for (int j = 0; j < CrunchifyWidth; j++) {
                if (byteMatrix.get(i, j)) {
                    graphics.fillRect(i, j, 1, 1);
                }
            }
        }
        ImageIO.write(image, fileType, myFile);
        //System.out.println("\n\nYou have successfully created QR Code " + myFile.getCanonicalPath());
        return myFile.getCanonicalPath();
    } catch (WriterException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:LineBreakMeasurerDemo.java

public DisplayPanel() {
    setBackground(Color.white);
    setSize(350, 400);//from w ww .  j  a v a  2  s  .  c om
    attribString = new AttributedString(text);
    attribString.addAttribute(TextAttribute.FOREGROUND, Color.blue, 0, text.length());
    Font font = new Font("sanserif", Font.ITALIC, 20);
    attribString.addAttribute(TextAttribute.FONT, font, 0, text.length());
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    GradientPaint p = new GradientPaint(0, 0, Color.white, getWidth(), getHeight(), Color.gray);
    g2d.setPaint(p);/* ww w.jav  a  2s .co  m*/
    g2d.fillRect(0, 0, getWidth(), getHeight());
}

From source file:com.aw.swing.mvp.grid.RowColorBkgChanger.java

private Color getColor(Object row) {
    if (row == lastRow) {
        return lastColor;
    }/*from w  w w.  ja  v  a  2  s  . c o  m*/
    Color color = Color.WHITE;
    if (condition.test(row)) {
        color = Color.RED;
    }
    lastColor = color;
    lastRow = row;
    return color;
}

From source file:Main.java

public void mouseReleased(MouseEvent me) {
    mmad.setBackground(Color.white);
    mmad.repaint();
}