The Artima Developer Community
Sponsored Link

Java Answers Forum
Converting from canvas to JPanel

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Tom

Posts: 1
Nickname: fryertom
Registered: Aug, 2003

Converting from canvas to JPanel Posted: Aug 7, 2003 4:19 AM
Reply to this message Reply
Advertisement
Ok I'm new to this subject, so go easy on me:

I have been trying to convert an applet from awt to swing. My applet contained an inner class which extended the Canvas class, and this class overrided the paint method to draw a square grid using the fillRect(x,y,width, height) method. So to convert it to swing, instead of making the class extend Canvas, I decided to make it extend JPanel, and I changed the paint(Graphics g) method to paintComponent(Graphics g). The problem is that now the grid is only 1 line high. The width is fine, but the height is a problem. I haven’t made a mistake with the parameters entered in the fillRect method, and when I change the class back to a subclass of canvas, the grid appears to be fine again.

Topic: Report generator tool in Java... Previous Topic   Next Topic Topic: JScrollPane  problem

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use