List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:MyCanvas.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; //Draw the chord Arc2D.Float arc1 = new Arc2D.Float(Arc2D.CHORD); arc1.setFrame(140, 30, 67, 46);// ww w .j a va2 s .c om arc1.setAngleStart(45); arc1.setAngleExtent(270); g2.setColor(Color.blue); g2.draw(arc1); g2.setColor(Color.gray); g2.fill(arc1); g2.setColor(Color.black); g2.drawString("Arc2D.CHORD", 140, 20); }
From source file:MyCanvas.java
public void draw(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Draw the pie chart Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE); arc.setFrame(140, 200, 67, 46);//from www . j a v a 2s . c om arc.setAngleStart(45); arc.setAngleExtent(270); g2.setColor(Color.gray); g2.draw(arc); g2.setColor(Color.red); g2.fill(arc); g2.setColor(Color.black); g2.drawString("Arc2D.PIE", 140, 190); }
From source file:Main.java
public Main() { setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); table = new Hashtable<Integer, Color>(); table.put(1, Color.RED);/*from w w w.ja v a2 s . c o m*/ table.put(2, Color.BLUE); table.put(3, Color.GREEN); table.put(4, Color.GRAY); c = new JComboBox<String>(); c.addItem("Item 1"); c.addItem("Item 2"); c.addItem("Item 3"); c.addItem("Item 4"); c.addItem("Item 5"); c.addItem("Item 6"); c.addItem("Item 7"); c.addItem("Item 8"); c.setRenderer(new MyListCellRenderer(table)); add(c); setSize(400, 400); setVisible(true); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2D;/* www . j a va2 s .c o m*/ g2D = (Graphics2D) g; FontRenderContext frc = g2D.getFontRenderContext(); Font font1 = new Font("Courier", Font.BOLD, 24); String str1 = new String("Java"); TextLayout tl = new TextLayout(str1, font1, frc); g2D.setColor(Color.gray); tl.draw(g2D, 70, 150); }
From source file:org.jfree.chart.demo.MeterChartDemo1.java
private static JFreeChart createChart(ValueDataset valuedataset) { MeterPlot meterplot = new MeterPlot(valuedataset); meterplot.setRange(new Range(0.0D, 60D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128))); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(260);//from w w w. j ava 2s .c om meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); JFreeChart jfreechart = new JFreeChart("Meter Chart 1", JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); return jfreechart; }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e = new Ellipse2D.Float(40, 40, 120, 120); GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95, Color.gray, true); g2.setPaint(gp);//from w w w .j a v a 2 s . co m g2.fill(e); }
From source file:Main.java
public static void addPlaceHolder(final JTextField field, final String placeHolderText) { field.addFocusListener(new FocusListener() { private Color fontColor = field.getForeground(); // private String previousText=field.getText(); public void focusGained(FocusEvent arg0) { if (field.getText().equals(placeHolderText)) { field.setText(""); }//w w w .ja v a2 s . c o m field.setForeground(fontColor); } public void focusLost(FocusEvent arg0) { if (field.getText().trim().equals("")) { fontColor = field.getForeground(); field.setForeground(Color.GRAY); field.setText(placeHolderText); } } }); if (field.getText().trim().equals("")) { field.setText(placeHolderText); field.setForeground(Color.GRAY); } }
From source file:SimpleLayers.java
public SimpleLayers() { super("LayeredPane Demonstration"); setSize(200, 150);/*from w w w . jav a 2s.co m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); JLayeredPane lp = getLayeredPane(); // Create 3 buttons JButton top = new JButton(); top.setBackground(Color.white); top.setBounds(20, 20, 50, 50); JButton middle = new JButton(); middle.setBackground(Color.gray); middle.setBounds(40, 40, 50, 50); JButton bottom = new JButton(); bottom.setBackground(Color.black); bottom.setBounds(60, 60, 50, 50); // Place the buttons in different layers lp.add(middle, new Integer(2)); lp.add(top, new Integer(3)); lp.add(bottom, new Integer(1)); }
From source file:org.jfree.chart.demo.MeterChartDemo3.java
private static JFreeChart createChart(String s, ValueDataset valuedataset, DialShape dialshape) { MeterPlot meterplot = new MeterPlot(valuedataset); meterplot.setDialShape(dialshape);//w w w . jav a 2 s.co m meterplot.setRange(new Range(0.0D, 60D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128))); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setMeterAngle(260); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); JFreeChart jfreechart = new JFreeChart(s, JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); return jfreechart; }
From source file:Overlap.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double x = 15, y = 50, w = 70, h = 70; Ellipse2D e = new Ellipse2D.Double(x, y, w, h); g2.setStroke(new BasicStroke(8)); Color smokeyColor = new Color(128, 128, 128, 128); g2.setPaint(smokeyColor);/*from w w w. jav a2s. c om*/ g2.fill(e); g2.draw(e); e.setFrame(x + 100, y, w, h); g2.setPaint(Color.black); g2.draw(e); g2.setPaint(Color.gray); g2.fill(e); e.setFrame(x + 200, y, w, h); g2.setPaint(Color.gray); g2.fill(e); g2.setPaint(Color.black); g2.draw(e); }