// 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(1280, 960); setVisible(true); } @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; // cast to Graphics2D g2d.scale(10.0, 10.0); // try different scale factors g2d.draw(new Rectangle2D.Double(20.75, 45.0, 60.0, 30.00) ); g2d.fill(new Rectangle2D.Double(67.33, 60.0, 8.0, 15.00) ); g2d.fill(new Rectangle2D.Double(35.00, 55.0, 20.3, 11.00) ); GeneralPath triangle = new GeneralPath(); triangle.moveTo(10.75, 46.0); // first point triangle.lineTo(90.75, 46.0); // move left triangle.lineTo(50.75, 10.0); // move to tip triangle.closePath(); g2d.fill(triangle); } } public class House2D { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { MyGui myGUI = new MyGui(); myGUI.createGUI(); } }); } }