• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Best way to decorate a JComponent

Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've build a GUI that has several different JComponents: JLists, JPanels, JTextAreas etc. Now I'm looking for a good way to set a few properties (e.g. Border, Back/Foreground color, Font, Layout) to the same value. E.g. all components have to have the same colors, and some of them a particular border, etc.

What is the most elegant way to do this?

A few considerations:
* avoid duplicate code
* preferable instantiation in 1 line
* avoid an exponential grow of classes

Any thoughts about this? Seems to me that this problem is very common.
    Bookmark Topic Watch Topic
  • New Topic