• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling repaint

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I open up a page with my JApplet in it and then bring up Windows Explorer over the page the contents of the page seem to fill into the JApplet's area on the page. When/how can I repaint the page each time it becomes visible again? Thanks.
 
Rob Camick
Ranch Hand
Posts: 2676
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Repainting happens automatically. You must have added code to your JApplet to prevent this from happening.

You probably overrode the paint() method which is a no-no.

Post your SSCCE that demonstrates the problem.
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
Thanks for the feedback. I saw your post after I had made the necessary changes but yes - you are correct. I created a JPanel and drawed my images and such on there then added to the JApplet. Seems to be fine now. Since I was adding images, text, etc.., directly what approach would you take? Although it looks to be working fine now I'm always open to hearing alternative and/or better ways of doing things. I haven't done much with Java and the little I have was quite some time ago, really appreciate the feedback. Thanks again.

Rob
 
Rob Camick
Ranch Hand
Posts: 2676
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a JPanel and drawed my images and such on there then added to the JApplet.


That is the way it should be done.

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm I have 3 classes declared in one package (let's call package1) and 2 in another (let's call package2) and both are in the same directory. In package1, I have a JApplet class that uses a bunch of small JPanels are put within a larger JPanel utilizing GridBagLayout. The JApplet class takes the larger JPanel just mentioned and puts it into a JScrollPane and adds it to it's content pane. The problem? Well first when the applet display everything looks fine. The smaller JPanels mentioned have some graphics drawn on them and have a background colour each. If you try and scroll to the JPanels you can't see nothing is shown. The initial area of display in the JScrollPane is the only content that remains. IF I take all the classes in both packages and merge them into 1 class everything works fine. The main class compiles the classes as though package1$class1, package1$class2, etc.., then.
My question is what differences are there between between having the classes in 1 class like this or in different packages and imported accordingly? It's more organized having them separated into separate class files but that doesn't seem to be working for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic