Skip to content

Instantly share code, notes, and snippets.

@mwibutsa
Created March 24, 2019 16:23
Show Gist options
  • Save mwibutsa/ed7592e2b0e0441be65999cfe31e1f74 to your computer and use it in GitHub Desktop.
Save mwibutsa/ed7592e2b0e0441be65999cfe31e1f74 to your computer and use it in GitHub Desktop.
Java Assignment
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Polygon extends JFrame {
public Polygon() {
setSize(400, 500);
setLayout(null);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Drawing Polygons");
}
public void paint(Graphics g) {
int [] x = {200, 400, 450, 400, 200, 150};
int [] y = {50, 50, 150, 250, 250, 150};
g.drawPolygon(x, y, 6);
}
public static void main (String [] args) {
new Polygon();
System.out.println("Hello java");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment