File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting contents visible/invisible

 
Saulo Menezes
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!
I am a novice in Java and I would really need your help, as I am struggling with the code. I have created an Applet that displays information about a fictitious company but I would like this info to change, depending on which button the user presses. All the components (info) in the Applet are part of a paint method: lines, strings and images mainly.
Which kind of procedure would I need to allow this to occur? Could I have two or more paint methods working based on each button that will be pressed? I mean once the Applet is loaded a paint method would be called, if a button is pressed that paint would not be valid anymore and another would be called and so on and so forth.
If this is possible, could you give me a hint on how to do it? I would be grateful.
Yours,
Saulo
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Saulo!
To better help others here to help you, post some code that you've been working. Explain what it does, or what you wish it did and why. Also explain how you think you might be able to change it to do what you want.
Note: When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.
 
Saulo Menezes
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the code to my Applet. What I intend to do is to make components from the painting method to be painted only if a certain variable is true.
In this way I intend display info - images, strings, ect - only if a certain button is clicked, which would allow me to control what is going to be displayed on my Applet.
To test it I tried this code but now that I have added the booleans b1, b2, b3, b4 and their parameters the images simply vanished... Would somebody be able to explain me why this is happening and give me a hint of how I can solve this problem? Many thanks!
Saulo
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saulo,
One way to do it would be to have some integer value that your paint method can use.

You could have your button actionListener set the paintNumber.
Regards,
Manfred.
 
Saulo Menezes
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the help, Manfred. This will be really useful for me.
Saulo
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic