This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Drawing Graphics in Layers?  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a tricky question, where I am not sure if java would supprot what I need.
I am drawing grahps using Graphics in a class that exdends Applet.
I would like to be able to draw two different things on the same 'canvas' without overwriting one another. Something that comes to mind as analogy is Layers but I couldn't find if Graphics has this or similar feature.
Basically, right now, if I want to draw something new on the canvas, I have to erase (owervrite) what was there before but I don't want to do that. I want to be able to add something on top of the old graphic and then later remove what I had drawn on top and still have the old graphic be there intact.
Any suggestions if this is possible and if yes, how I can do that?
(I am using Graphics methods such as: g.drawString, g.drawLine, g.drawLine etc.)
Help appreciated,
Ivan
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not very sure about what you want but I think you have 2 options -
(1) Use Card Layout
(2) Or use canvas, make them transparent (guess it's possible) and place them accordingly.
HTH,
- manish
 
Ivn Tcakov
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response,
I looked into your suggestions and I don't think that is what I am looking for.
I want to draw a Line (or many lines) on top of my canvas over the background while I still see the background around it (so, I can't use CardLayout) and I want to see the line (so I can't make it transparent).
Now, once the line has been drawn on my Applet (canvas) I want to be able to erase it without erasing the stuff that had been drawn in the background before that.
SO I need some kind of 'layering' like you suggested but so that it would work the way I described above.
Maybe I didn't figure out your suggestions properly. LEt me know if that's the case.
Again, thanks for the suggestion.
Ivan
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!