Created
February 23, 2019 08:01
-
-
Save fernandozamoraj/74483ac9ae4be1582f4e2aeba9ff6f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
class Window extends Frame{ | |
Window(){ | |
setSize(800,900);//frame size 300 width and 300 height | |
setLayout(null);//no layout manager | |
setVisible(true);//now frame will be visible, by default not visible | |
} | |
@Override | |
public void paint(Graphics g) { | |
// TODO Auto-generated method stub | |
super.paint(g); | |
//draw an orange line | |
g.setColor(Color.ORANGE); | |
g.drawLine(10,200,400,200); | |
//draw a circle | |
g.fillOval(100, 100, 200, 200); | |
//change color to red | |
g.setColor(Color.RED); | |
//draw filled rectangle | |
g.fillRect(10, 300, 400, 40); | |
//change color to green and draw another rectangle | |
g.setColor(Color.GREEN); | |
g.fillRect(100, 300, 200, 100); | |
//draw another rectangle | |
g.drawRect(100, 450, 300, 30); | |
//create points to form a hexagon | |
//draw the hexago | |
int[] xPoints = {210, 240, 280, 310, 280, 240, 210}; | |
int[] yPoints = {600, 550, 550, 600, 650, 650, 600}; | |
g.drawPolygon(xPoints, yPoints, 7); | |
} | |
public static void main(String args[]){ | |
Window w=new Window(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment