Created
October 2, 2017 12:34
-
-
Save sugiartocokrowibowo/94beb585cfffc2dbda62b6582b71ed74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 java.awt.Color; | |
| import java.awt.EventQueue; | |
| import java.awt.Graphics; | |
| import java.awt.Graphics2D; | |
| import javax.swing.JComponent; | |
| import javax.swing.JFrame; | |
| public class Main extends JFrame { | |
| public Main(){ | |
| initUI(); | |
| } | |
| private void initUI() { | |
| add(new Canvas()); | |
| setTitle("Computer Graphics"); | |
| setSize(1024, 600); | |
| setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
| setLocationRelativeTo(null); | |
| } | |
| public static void main(String[] args){ | |
| EventQueue.invokeLater(new Runnable(){ | |
| public void run() { | |
| Main unsulbar = new Main(); | |
| unsulbar.setVisible(true); | |
| } | |
| }); | |
| } | |
| public class Canvas extends JComponent { | |
| public void paint(Graphics g) { | |
| Graphics2D g2d = (Graphics2D) g; | |
| g2d.setColor(Color.decode("#3498db")); | |
| g2d.fillRect(100, 100, 200, 200); | |
| g2d.dispose(); | |
| //--------------------------------------------------------------------------------------------------- | |
| }//end of paint(Graphics g) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment