Created
March 9, 2013 20:49
-
-
Save figengungor/5125697 to your computer and use it in GitHub Desktop.
Java GUI >> Draw a Rectangle
This file contains 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 javax.swing.JFrame; | |
import java.awt.Graphics; | |
import java.awt.Color; | |
public class MyGUI extends JFrame | |
{ | |
public MyGUI() | |
{ | |
setTitle("Tutorial"); | |
setSize(960,960); | |
setVisible(true); | |
setDefaultCloseOperation(EXIT_ON_CLOSE); | |
} | |
public void paint(Graphics g) | |
{ | |
g.setColor(Color.RED); | |
g.drawRect(480, 480, 200, 100); | |
g.setColor(Color.BLUE); | |
g.fillRect(240, 240, 200, 100); | |
} | |
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