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

/**
 * Set the button to have simplified UI.
 * /*from www .  j  a  va  2s. 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:DropTest.java

public DropTest() {
    super("Drop Test");
    setSize(300, 300);/*from w  ww .  ja  v a 2 s . co  m*/

    getContentPane().add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    // Set up our text area to recieve drops...
    // This class will handle drop events
    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:GradientPaintEllipse.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int x = 5;//from  w ww.  java2s . c  o  m
    int y = 7;

    // fill Ellipse2D.Double
    GradientPaint redtowhite = new GradientPaint(x, y, Color.red, 200, y, Color.white);
    g2.setPaint(redtowhite);
    g2.fill(new Ellipse2D.Double(x, y, 200, 200));
    g2.setPaint(Color.black);
    g2.drawString("Filled Ellipse2D", x, 250);
}

From source file:st.jigasoft.dbutil.util.ReportTheme.java

public static void circularTheme(JFreeChart chart, String... colunsName) {
    chart.setBackgroundPaint(//from  w  ww .  j  av  a2  s .  c o  m
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);
    int iCount = 0;

    // use gradients and white borders for the section colours
    for (Object s : colunsName) {
        plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++)));
        if (iCount == MAX_COLUNS_COLOR)
            iCount = 0;
    }

    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    //        // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
}

From source file:NewDropTest.java

public NewDropTest() {
    super("Drop Test");
    setSize(300, 300);/*from  w  w  w .  j a  v  a2  s  .co  m*/

    getContentPane().add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    // Set up our text area to recieve drops...
    // This class will handle drop events
    // dt = new DropTarget(ta, this);
    setVisible(true);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Item Label Demo 3", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);//from  w ww .  jav  a  2  s  .c  o m
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.14999999999999999D);
    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator(
            "{1}", NumberFormat.getInstance());
    categoryitemrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator);
    categoryitemrenderer.setBaseItemLabelFont(new Font("SansSerif", 0, 12));
    categoryitemrenderer.setBaseItemLabelsVisible(true);
    categoryitemrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER, TextAnchor.CENTER, -1.5707963267948966D));
    return jfreechart;
}

From source file:ExtendedParagraphExample.java

public static void createDocumentStyles(StyleContext sc) {
    Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);

    // Create and add the main document style
    Style mainStyle = sc.addStyle(mainStyleName, defaultStyle);
    StyleConstants.setLeftIndent(mainStyle, 16);
    StyleConstants.setRightIndent(mainStyle, 16);
    StyleConstants.setFirstLineIndent(mainStyle, 16);
    StyleConstants.setFontFamily(mainStyle, "serif");
    StyleConstants.setFontSize(mainStyle, 12);

    // Create and add the constant width style
    Style cwStyle = sc.addStyle(charStyleName, null);
    StyleConstants.setFontFamily(cwStyle, "monospaced");
    StyleConstants.setForeground(cwStyle, Color.white);

    // Create and add the heading style
    Style heading2Style = sc.addStyle(heading2StyleName, null);
    StyleConstants.setForeground(heading2Style, Color.red);
    StyleConstants.setFontSize(heading2Style, 16);
    StyleConstants.setFontFamily(heading2Style, "serif");
    StyleConstants.setBold(heading2Style, true);
    StyleConstants.setLeftIndent(heading2Style, 8);
    StyleConstants.setFirstLineIndent(heading2Style, 0);

    // Create and add the extended para styles
    Style paraStyle = sc.addStyle(paraStyleName, null);
    Color bgColor = Color.gray;
    ExtendedStyleConstants.setParagraphBackground(paraStyle, bgColor);
    ExtendedStyleConstants.setParagraphBorder(paraStyle,
            BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
                    BorderFactory.createCompoundBorder(
                            BorderFactory.createEtchedBorder(bgColor.brighter(), bgColor.darker()),
                            BorderFactory.createEmptyBorder(4, 4, 4, 4))));
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //A specialised subclass of the {@link XYLineAndShapeRenderer} that requires
    // an {@link IntervalXYDataset} and represents the y-interval by shading an
    // area behind the y-values on the chart.
    DeviationRenderer renderer = new DeviationRenderer(true, false);
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1));
    renderer.setSeriesFillPaint(0, new Color(255, 200, 200));
    renderer.setSeriesFillPaint(1, new Color(200, 200, 255));
    plot.setRenderer(renderer);/*w  w w . jav a  2s  .  c  o m*/
    //
    NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createWaterfallChart("Product Cost Breakdown", "Expense Category",
            "Cost Per Unit", categorydataset, PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    ValueAxis valueaxis = categoryplot.getRangeAxis();
    DecimalFormat decimalformat = new DecimalFormat("##,###");
    decimalformat.setNegativePrefix("(");
    decimalformat.setNegativeSuffix(")");
    TickUnits tickunits = new TickUnits();
    tickunits.add(new NumberTickUnit(5D, decimalformat));
    tickunits.add(new NumberTickUnit(10D, decimalformat));
    tickunits.add(new NumberTickUnit(20D, decimalformat));
    tickunits.add(new NumberTickUnit(50D, decimalformat));
    tickunits.add(new NumberTickUnit(100D, decimalformat));
    tickunits.add(new NumberTickUnit(200D, decimalformat));
    tickunits.add(new NumberTickUnit(500D, decimalformat));
    tickunits.add(new NumberTickUnit(1000D, decimalformat));
    tickunits.add(new NumberTickUnit(2000D, decimalformat));
    tickunits.add(new NumberTickUnit(5000D, decimalformat));
    valueaxis.setStandardTickUnits(tickunits);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBase(5D);//  w w  w  .j a va2 s. c  om
    DecimalFormat decimalformat1 = new DecimalFormat("$##,###.00");
    decimalformat1.setNegativePrefix("(");
    decimalformat1.setNegativeSuffix(")");
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1));
    barrenderer.setBaseItemLabelsVisible(true);
    return jfreechart;
}

From source file:Main.java

public ColorRenderer(JComboBox comboBox) {
    this.comboBox = comboBox;
    border = new LineBorder(Color.WHITE);
}