On 14 Paź, 14:37, Hole <h0lefor...@gmail.com> wrote:
> Good Afternoon,
>
> I have a nice JDialog window showing multiple progress bars.
> Now, I would like to add decorated progress bars (it should be a panel
> with a JLabel and a JProgressBar) to the JDialog's content pane so I
> guessed I need to create a new component by Decorator pattern applied
> to JProgressBar.
>
> I read the decorator Â*pattern documentation but I'm quite confused.
> Does the decorator class extend the component that is being decorated
> or the component that decorate?
Hi
No, decorator typically does not extend decorated class (though it
usually extends some shared base class).
What you probably want to do is to make a composite component with
JLabel and a progress bar as its parts and delegate painting to them
(you might want LayoutManager instance as well). The other way is to
extend JProgressBar and redefine its painting method as needed (or UI
painting method). Nice example of composite controls is here:
https://flamingo.dev.java.net - browse CVS for JSlider, it is very
simple control so you should not have trouble in understanding what is
going on there.