Forums Register Login

setting contents visible/invisible

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks a lot for the help, Manfred. This will be really useful for me.
Saulo
Grow your own food... or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1578 times.
Similar Threads
Servlet to Applet communication
How to press JButtons from within the program?
AWT Applet vrs SWING applet
graphics object
How to code a button with image
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:45:14.