Skip to content

Instantly share code, notes, and snippets.

@figengungor
Created March 9, 2013 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figengungor/5125743 to your computer and use it in GitHub Desktop.
Save figengungor/5125743 to your computer and use it in GitHub Desktop.
Java GUI >> Draw a Line
import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Color;
public class MyGUI extends JFrame
{
public MyGUI()
{
setTitle("Tutorial");
setSize(400,400);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
g.setColor(Color.green);
g.drawLine(100, 200, 350, 200);
}
public static void main(String[] args)
{
MyGUI frame = new MyGUI();
frame.paint(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment