wood burning stoves 2.0*
The moose likes Applets and the fly likes setting contents visible/invisible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "setting contents visible/invisible" Watch "setting contents visible/invisible" New topic
Author

setting contents visible/invisible

Saulo Menezes
Greenhorn

Joined: Jan 15, 2003
Posts: 17
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

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Saulo Menezes
Greenhorn

Joined: Jan 15, 2003
Posts: 17
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

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Jan 15, 2003
Posts: 17
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
 
subject: setting contents visible/invisible
 
Similar Threads
Servlet to Applet communication
AWT Applet vrs SWING applet
How to code a button with image
graphics object
How to press JButtons from within the program?