So, how do we incorporate graphics into our java code?
If you remember working with the Breezy drop-down boxes from previous
units, you will recognize the structure of this new graphics' code.
You will fill in the red
areas with your programming code.
The other items should remain constant, for now.
import java.awt.*;
import BreezyGUI.*;
public class graphicsName extends GBFrame
{
public void paint(Graphics g)
{
g.setColor(Color.green);
int [ ] x = {75,
150, 120};
int [ ] y = {75,
140, 50};
g.fillPolygon(x, y,
3);
}
public static void main (String[ ] args)
{
Frame frm = new
graphicsName( );
frm.setSize (300,300);
frm.setVisible(true);
}
}

|