Skip to content

Instantly share code, notes, and snippets.

@everblut
Created February 24, 2012 22:08
Show Gist options
  • Save everblut/1904105 to your computer and use it in GitHub Desktop.
Save everblut/1904105 to your computer and use it in GitHub Desktop.
Luz
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Luz extends JPanel{
Color on;
int radius = 20;
int border = 3;
boolean active;
Luz(Color color){
on = color;
active = false;
}
public void turnOn(boolean a) {
active = a;
repaint();
}
public Dimension getPreferredSize(){
int size = (radius+border)*2;
return new Dimension( size, size );
}
public void paintComponent(Graphics g){
g.setColor( Color.black );
g.fillRect(0,0,getWidth(),getHeight());
if (active){
g.setColor( on );
} else {
g.setColor( on.darker().darker().darker() );
}
g.fillOval( border,border,2*radius,2*radius );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment