Results 1 to 2 of 2
- 12-03-2009, 09:27 PM #1
How to duplicat drawOval horizontally?
Hi guyz,
I have a paint method that draws a circle with crossed-diagonal lines as follows
Now I need to duplicate the circle with cross 6 time horizontally, how can i do that and place it into a Jpanel. below is my what i've.Java Code:public void paint(Graphics Grafix){ Grafix.drawLine(10, 20, 50, 70); Grafix.drawLine(50, 20, 10, 70); Grafix.drawOval(5, 20, 50, 50); }
Thanks a lot:)Java Code:panel_1 = new JPanel(); panel_1.setBackground(Color.green); add(panel_1);Life is not perfect, but the way you live it can make it perfectly wongerful :cool:
- 12-03-2009, 09:37 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
1) Learn standard Java naming conventions. Every book, tutorial, or example I've seen posted in the forums follow these basic standards. Don't make up your own. Variable name should NOT start with an upper cased character.
2) Custom painting on a component is done by overriding the paintComponent() method NOT the paint() method. However, I am going to suggest a different approach.
Create a custom Icon. In this case the custom painting is done in the paintIcon(...) method.
Now you can add the icon to multiple JLabels and add your labels to your panel.
If you need more help post your SSCCE showing the problem.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks