// This code example is created for educational purpose
// by Thorsten Thormaehlen (contact: www.thormae.de).
// It is distributed without any warranty.

import java.awt.*;
import java.awt.geom.*;
import java.awt.geom.Line2D;

import javax.swing.*;

class MyGui extends JFrame {
  public void createGUI() {
    setTitle("HelloGUI");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(320, 240);
    setVisible(true);
  }
  @Override
  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g; // cast to Graphics2D
    GeneralPath gp = new GeneralPath(); 
    gp.moveTo( 50,  50); // start here
    gp.lineTo( 50,  70); // going down
    gp.lineTo(100,  70); // going right
    gp.lineTo(100, 180); // going down
    gp.lineTo(120, 180); // going right
    gp.lineTo(120,  70); // going up
    gp.lineTo(170,  70); // going right
    gp.lineTo(170,  50); // going up
    gp.lineTo( 50,  50); // going left (back to start)
    
    g2d.draw(gp); // also try g2d.fill(gp); 
  }
}

public class MyGeneralPath {
  public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        MyGui myGUI = new MyGui();
        myGUI.createGUI();
      }
    });
  }
}

