• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Canvas and JPanel

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to put a canvas in a JPanel so that I can do some drawing. The canvas must cover the entire space of the JPanel. Whenever I resize the JPanel, the canvas must also be resized.

I think I have to set the size (setSize) of the canvas. But I don't know how to get the size of the JPanel.

Or is there any other better way (on setting the size of the canvas) ?

Thank you.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where would you like the answer posted?

here, javaworld, any of the other places you cross-post to?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
where would you like the answer posted?

here, javaworld, any of the other places you cross-post to?



Cross-posting is quite alright so long as it's not the same message board. I often post the same question on 2-3 different boards. Then I get a better chance at getting a response.

William, why do you want to put a canvas on a JPanel? Why not simplify things and just draw on the JPanel. All you have to do is override the paintComponent method.
 
william brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. You are right Mr Gregg Bolinger. I just want to get more idea from the answers because I dont think everybody here are also in the other forums. Sorry if you dont feel happy with it, Mr Michael Dunn.

Thank you Mr Gregg Bolinger for your good idea. You have really helped me.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic