Results 1 to 11 of 11
- 10-16-2011, 01:59 AM #1
-
Re: Paint Graphics2D objects onto a JPanel
- 10-16-2011, 02:59 AM #3
Re: Paint Graphics2D objects onto a JPanel
<s>im sorry but i cannot seem to find the paintComponent method in the java doc. am i looking in the worng place?
JPanel (Java Platform SE 6)</s>
edit: sorry i missed the last sentence that talked about jcomponentLast edited by sublixt; 10-16-2011 at 03:04 AM.
-
Re: Paint Graphics2D objects onto a JPanel
- 10-16-2011, 03:32 AM #5
Re: Paint Graphics2D objects onto a JPanel
one more question how do i recall the paintComponent method after the first time that it is called?
-
Re: Paint Graphics2D objects onto a JPanel
- 10-16-2011, 03:40 AM #7
Re: Paint Graphics2D objects onto a JPanel
hmm i am doing a very bad job at reading the javadocs i was looking particularity for that method. Well thanks for the help.
-
Re: Paint Graphics2D objects onto a JPanel
If you want a more advanced tutorial on painting with Swing and AWT, please have a look at this great article: Painting in AWT and Swing
- 10-16-2011, 06:18 AM #9
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: Paint Graphics2D objects onto a JPanel
In this case a better place to start is: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)hmm i am doing a very bad job at reading the javadocs i was looking particularity for that method.
- 10-28-2011, 11:55 AM #10
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Re: Paint Graphics2D objects onto a JPanel
here I will write simple code for you
-class myDrawing extends JPanel{
- public myDrawing(){
-
- }
- protected void paintComponent(Graphics g){
- Graphics2D g2=(Graphics2D) g;
- Shape p=new Rectangle(0,0,100,100);
- g2.setColor(Color.RED);
- g2.draw(p);
- g2.fill(p);
- }
- public static void main(String[] args){
- JFrame myFrame=new JFrame();
- myFrame.setBounds(0,0,500,500);
- myFrame.add(new myDrawing());
- myFrame.setVisible(true);
-}
I have not compiled this code I only write in reply thread
But in this forum, I wrote a code before about drawings and mouse click detection in that drawing
- 10-28-2011, 11:57 AM #11
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Similar Threads
-
How To Draw Objects Not On A JPanel
By anthropamorphic in forum New To JavaReplies: 18Last Post: 08-11-2011, 05:55 AM -
Placing a new JPanel over a paint overriden JPanel
By Tanshaydar in forum AWT / SwingReplies: 4Last Post: 12-08-2010, 06:00 PM -
Java Paint Program problem (JPanel)
By KilKidd in forum Advanced JavaReplies: 6Last Post: 11-20-2010, 04:31 AM -
paint vs paintComponent for a JPanel
By lightstream in forum AWT / SwingReplies: 4Last Post: 01-29-2009, 02:26 AM -
help?! paint on top of swing components on JPanel
By beam2008 in forum AWT / SwingReplies: 1Last Post: 12-05-2008, 04:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks