Results 1 to 8 of 8
Thread: Paint problem =P
- 02-07-2011, 10:04 PM #1
Paint problem =P
Im a newbeginner on painting in java ... Im trying to paint a circle in a JPanel.
I made a class for the painting:
and in my GUI constructor i made a object and added it to my panel.Java Code:import javax.swing.*; import java.awt.*; public class Graphic extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.BLACK); g.fillOval(400, 400, 50, 50); } }
so why is it not painting anyting??? ThanksJava Code:Graphic g = new Graphic(); cordinatepanel.add(g);
-
Do you know if your Graphic panel is big enough to show the drawing, that it is larger than 400 by 400? After adding your Graphic JPanel and rendering your GUI (calling pack() or setVisible(true) on the top-level container), you may wish to call System.out.println(g.getSize()) to see how big the panel is.
- 02-07-2011, 10:16 PM #3
the panel is y: 640 x :1200 =/
-
- 02-07-2011, 10:25 PM #5
no not position ... cordinatepanel.setSize(1200, 640);
- 02-07-2011, 10:27 PM #6
My problem is ... i wrote this GPS application ... and now i want to draw my pos on a image witch is an imageicon ... just want to paint a circle at the cordinate where the GPS pos is ...
-
- 02-08-2011, 09:29 AM #8
Similar Threads
-
About super.paint()
By jordan2816 in forum Java AppletsReplies: 1Last Post: 01-24-2011, 11:14 AM -
Java Paint Program problem (JPanel)
By KilKidd in forum Advanced JavaReplies: 6Last Post: 11-20-2010, 04:31 AM -
paint and repaint problem
By koddy in forum NetBeansReplies: 2Last Post: 05-21-2010, 06:43 AM -
how to add more than one paint method
By gautham in forum Java 2DReplies: 2Last Post: 04-06-2010, 07:07 AM -
Some confusions with paint()
By kendaop in forum Java AppletsReplies: 1Last Post: 01-24-2009, 12:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks