This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

setting contents visible/invisible

 
Greenhorn
Posts: 17
  • 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
 
Sheriff
Posts: 7023
  • 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
  • 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
 
Ranch Hand
Posts: 1492
  • 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
  • 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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic