Results 1 to 4 of 4
  1. #1
    nonybrighto is offline Member
    Join Date
    Oct 2012
    Location
    ph
    Posts
    43
    Rep Power
    0

    Default Drawing colored shape!!!

    pls i need some help here from u guys...i just learnt about coloring now ANd i had a problem when i compiled this ...i expected to get a result of a colored circle
    but i just get an empty frame with nothing in it...pls can anyone tell me where my problem is pls...

    Java Code:
    import java.awt.Graphics;
    import javax.swing.JPanel;
    import java.awt.Color;
    import javax.swing.JFrame;
    public class smilie extends JPanel{
        
        public void PaintComponent(Graphics g)
        {
            super.paintComponent(g);
            
            g.setColor(Color.RED);
            g.drawRect(10, 10, 15, 15);
            
        }
        
        public static void main(String[] args)
        {
           smilie show =new smilie();
           JFrame app=new JFrame();
           
           
           app.add(show);
           app.setSize(230, 250);
           app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           app.setVisible(true);
        }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Drawing colored shape!!!

    When overriding methods, you must be sure that you are in fact overriding a method. One way to test that is to put the @Override annotation just before the overridden method. I suggest that you try that now, and then after the compiler complains carefully look at your method's signature, its first line, to figure out why the compiler is complaining. You'll go "aha!", believe me, when you see it.

  3. #3
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Drawing colored shape!!!

    Hint: Paint != paint

  4. #4
    nonybrighto is offline Member
    Join Date
    Oct 2012
    Location
    ph
    Posts
    43
    Rep Power
    0

    Default Re: Drawing colored shape!!!

    Thnaks bro...i'll try it when i get back from church...

Similar Threads

  1. Button click for drawing geometry shape
    By nnur in forum AWT / Swing
    Replies: 5
    Last Post: 05-15-2010, 07:48 PM
  2. Replies: 1
    Last Post: 04-02-2010, 12:48 PM
  3. Drawing a shape on an image
    By Yoruichi in forum Java 2D
    Replies: 2
    Last Post: 03-29-2009, 02:49 PM
  4. SWT List w/ colored lines?
    By p!lle in forum SWT / JFace
    Replies: 1
    Last Post: 03-23-2009, 03:23 PM
  5. Shape drawing applet not working...
    By evapisces in forum Java Applets
    Replies: 0
    Last Post: 11-17-2008, 11:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •