Mini Project On Java: Title:Traffic Signals Using Java Dept: Cse Year: Ii - B
Mini Project On Java: Title:Traffic Signals Using Java Dept: Cse Year: Ii - B
DONE BY:
SUDHEER KUMAR.N
Software Used:
SIDRA INTERSECTION is a powerful software package for timing, capacity,
performance and level of service analysis of signalised intersections (junctions
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public TrafficLight(){
super("Traffic Light");
b1 = new JButton("Red");
b2 = new JButton("Yellow");
b3 = new JButton("Green");
b1.addActionListener(this);
b2.addActionListener(this);
green.turnOn(false);
yellow.turnOn(false);
red.turnOn(true);
p1.add(red);
p1.add(yellow);
p1.add(green);
p2.add(b1);
p2.add(b2);
p2.add(b3);
getContentPane().add(p1);
getContentPane().add(p2);
pack();
tl.setVisible(true);
if (e.getSource() == b1){
green.turnOn(false);
yellow.turnOn(false);
red.turnOn(true);
yellow.turnOn(true);
green.turnOn(false);
red.turnOn(false);
red.turnOn(false);
yellow.turnOn(false);
green.turnOn(true);
Color on;
boolean change;
Signal(Color color){
on = color;
change = true;
change = a;
repaint();
g.setColor( Color.black );
g.fillRect(0,0,getWidth(),getHeight());
g.setColor( on );
} else {
g.setColor( on.darker().darker().darker() );
g.fillOval( border,border,2*radius,2*radius );
OUTPUT: