IT-Academy

Java Grafika Tvary

May 31st, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6.  
  7. /**
  8.  *
  9.  * @author IT Academy
  10.  */
  11. public class Main extends JPanel {
  12.  
  13.     public static void main(String args[]) {
  14.         JFrame f = new JFrame("Kreslime v Jave");
  15.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  16.  
  17.         Main d = new Main();
  18.         f.add(d);
  19.         f.setSize(500, 280);
  20.         f.setVisible(true);
  21.     }
  22.  
  23.    
  24.    
  25.    
  26.     @Override
  27.     public void paintComponent(Graphics g) {
  28.         super.paintComponent(g);
  29.         this.setBackground(Color.WHITE);
  30.  
  31.         g.setColor(new Color(125,125,125));
  32.         g.drawLine(10, 10, 100, 30);
  33.  
  34.         g.setColor(Color.BLUE);
  35.         g.drawRect(10, 50, 100, 30);
  36.  
  37.         g.setColor(Color.ORANGE);
  38.         g.fill3DRect(10, 90, 100, 30, false);
  39.  
  40.         g.setColor(Color.cyan);
  41.         g.drawOval(10, 130, 100, 30);
  42.     }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment