List of usage examples for java.awt Graphics setColor
public abstract void setColor(Color c);
From source file:Main.java
public void paint(Graphics g) { g.setColor(Color.red); Graphics clippedGraphics = g.create(); clippedGraphics.drawRect(0, 0, 100, 100); clippedGraphics.clipRect(25, 25, 50, 50); clippedGraphics.drawLine(0, 0, 100, 100); clippedGraphics.finalize();//from ww w . j a v a 2s . c o m clippedGraphics = null; g.drawLine(0, 100, 100, 0); }
From source file:union.java
public void paint(Graphics g) { g.setColor(Color.lightGray); Rectangle r2 = r.union(r1);/* w ww . ja v a 2 s.c o m*/ g.fillRect(r2.x, r2.y, r2.width, r2.height); g.setColor(Color.black); g.drawRect(r.x, r.y, r.width, r.height); g.drawRect(r1.x, r1.y, r1.width, r1.height); }
From source file:MouseMotionEventDemo.java
public void paint(Graphics g) { g.setColor(Color.blue); g.fillRect(mX, mY, 5, 5); }
From source file:Main.java
public void paint(Graphics g) { g.setColor(curColor); g.fillRect(0, 0, getWidth() - 1, getHeight() - 1); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { g.setColor(Color.GREEN); g.fillRect(0, 0, getWidth(), getHeight()); // uncomment the following to draw an image // Image img = ...; // g.drawImage(img, 0, 0, this); super.paintComponent(g); }
From source file:Main.java
public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(Color.red); g.fillRect(0, 0, 33, 33);/* w ww.j a va 2 s .com*/ g.drawString("java2s.com", 0, 20); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); try {/*from w w w .jav a2s.c o m*/ Rectangle rect = modelToView(getCaretPosition()); if (rect != null) { g.setColor(Color.RED); g.fillRect(0, rect.y, getWidth(), rect.height); } } catch (BadLocationException e) { System.out.println(e); } super.paintComponent(g); }
From source file:Main.java
Main() { getRootPane().setGlassPane(new JComponent() { public void paintComponent(Graphics g) { g.setColor(new Color(0, 0, 0, 100)); g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); }/*from ww w.j a va 2 s. c om*/ }); JButton popDialog = new JButton("Block Frame"); popDialog.addActionListener(e -> { getRootPane().getGlassPane().setVisible(true); JOptionPane.showMessageDialog(Main.this, "Shady!"); getRootPane().getGlassPane().setVisible(false); }); setContentPane(popDialog); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(350, 180); }
From source file:LazySample.java
public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(Color.RED); g.fillRect(1, 1, 20, 20);/*from w w w. j a va 2 s . c om*/ }
From source file:Main.java
public void paint(Graphics g) { g.setColor(Color.BLACK); g.drawString("Applet background example", 0, 50); }