Results 1 to 4 of 4
Thread: Drawing colored shape!!!
- 10-28-2012, 12:42 AM #1
Member
- Join Date
- Oct 2012
- Location
- ph
- Posts
- 43
- Rep Power
- 0
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); } }
-
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.
- 10-28-2012, 12:54 AM #3
Senior Member
- Join Date
- Oct 2012
- Posts
- 108
- Rep Power
- 0
Re: Drawing colored shape!!!
Hint: Paint != paint
- 10-28-2012, 08:26 AM #4
Member
- Join Date
- Oct 2012
- Location
- ph
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
Button click for drawing geometry shape
By nnur in forum AWT / SwingReplies: 5Last Post: 05-15-2010, 07:48 PM -
how to change the shape of the JFrame to a oval shape
By kiki2009 in forum Java 2DReplies: 1Last Post: 04-02-2010, 12:48 PM -
Drawing a shape on an image
By Yoruichi in forum Java 2DReplies: 2Last Post: 03-29-2009, 02:49 PM -
SWT List w/ colored lines?
By p!lle in forum SWT / JFaceReplies: 1Last Post: 03-23-2009, 03:23 PM -
Shape drawing applet not working...
By evapisces in forum Java AppletsReplies: 0Last Post: 11-17-2008, 11:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks