0

What is better to use in java: a manually implemented double-buffering, or to use an already double-buffered swing component? Or is this without any difference?

Thank you.

default locale
  • 13,035
  • 13
  • 56
  • 62
T_01
  • 1,256
  • 3
  • 16
  • 35

1 Answers1

2

It's unclear what you mean by "better" (or for that matter, the specifics of "manually implemented double-buffering"), but two major points:

  1. It generally makes more sense to not reinvent wheels.
  2. Don't optimize prematurely. Unless you are seeing performance that does not meet your requirements and have benchmarked and determined that your double-buffering implementation is the cause, then you should not be asking this question.
Jason C
  • 38,729
  • 14
  • 126
  • 182
  • I dont agree. When i can reach something in two different ways, i usually want to know which way is better / faster / righter to use. All this can be only "better"... – T_01 Aug 06 '13 at 08:48
  • 5
    @T_01 The question lacks context. What are you rendering? What are you trying to achieve? I would say that in general, every day use, Swing's double buffering is more then efficient. You might use your own internal buffer where rendering the output via the normal paint chain is inefficient (because of complexity, for example) and paint that buffer as required – MadProgrammer Aug 06 '13 at 08:58
  • yes, that was what i meaned. It was an general question. – T_01 Aug 06 '13 at 10:54
  • Why would you implement it if there already is solution? This would be waste of your time. Even if you would create optimal double buffering solution, it would be build on top of Swing, so in result it would probably be slower. – Piro Aug 06 '13 at 11:46