Results 1 to 5 of 5
- 11-30-2010, 05:01 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 11
- Rep Power
- 0
how to draw oval using Graphics object
Hi,
I have one requirement.I have drawn one oval on panel using Graphics2D object.
But i want to display the oval on panel immediately after executing the class with out performing any action(mouse click event). I had written the code in constructor.Its not displaying. This one working perfectly when i place the code on any event of the panel. please help me.
Thanks in advance,
Usha.
-
Perhaps you will want to reveal to us the libraries that you're using (Swing vs AWT), and to show us the code you've used so far, especially the one that's not working?
- 11-30-2010, 07:22 AM #3
Recommended reading:
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
db
- 11-30-2010, 07:59 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 11
- Rep Power
- 0
how to draw oval using Graphics object
I used the following code. When i call this function from constructor its not working. Its working when i call this drawing function from mouse event of jPanel.
public class Example extends JFrame{
public Example(){
JPanel panel=new JPanel();
.....................................
..........................................
drawing();
}}
public void drawing(){
rd=(java.awt.Graphics2D)Panel.getGraphics();
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
rd.setRenderingHints(rh);
rd.drawOval(4,3,30,30);
rd.setColor(new java.awt.Color(83,125,249));
rd.fillOval(5,4,29,29);
rd.setColor(java.awt.Color.black);
rd.drawOval(p,q,7,7);
}
-
You apparently have not read the tutorials in the links the Darryl posted. I suggest you start there (as does he).
Similar Threads
-
Object Draw canvas Text
By kyle.g in forum New To JavaReplies: 0Last Post: 07-27-2010, 09:54 PM -
do I need to dispose of my Graphics object?
By gib65 in forum AWT / SwingReplies: 3Last Post: 07-06-2010, 05:04 AM -
Draw Graphics on top of another
By child in forum AWT / SwingReplies: 9Last Post: 01-17-2010, 04:14 PM -
How to set line width in Graphics object?
By inc_123 in forum New To JavaReplies: 8Last Post: 08-15-2009, 10:34 PM -
Trying to use Graphics draw methods
By Lang in forum SWT / JFaceReplies: 5Last Post: 03-26-2008, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks