|
Do a lot of research into the architecture of swing
components, first.
In summary, Swing uses its own version of MVC, where the
component is the public access point to the public model and the more private
combined view and controller, the UI delegate. The UI delegate will decide such
things as colours and how to respond to events. This behaviour may be specific
to the look and feel. So research Swing's pluggable look and feel (PLAF)
architecture as well.
Once you have looked into these two areas, feel free to ask
more questions.
----- Original Message -----
Sent: Thursday, October 03, 2002 3:32
AM
Subject: RE: What is this
JComponent?
Thanks Greg Munt and Vikram Kumar.
Because I am new to Java Swing and don't have any idea on how to design
custom UI delegate to a subclass of JButton, could you give me some detailed
info on this?
Thanks.
It depends. If you are absolutely never going to use more
than one look and feel, overriding paint() is adequate (although I would
prefer to assign a custom UI delegate to a subclass of
JButton).
If your application requires the ability to support
multiple look and feels, you have three choices:
1. Implement a custom UI delegate for each supported look
and feel. This allows the behaviour to vary with the look and
feel.
2. Do as above (override paint() or provide a single
custom UI delegate) - this will ensure that some behaviours of your
components do not vary with the look and feel, but is less time-consuming to
implement - especially if the number of look and feels you need to support
is large.
3. Implement your own look and feel, which provides this
new behaviour for JButtons. This new look and feel could extend another
already in existence, such as Metal.
----- Original Message -----
Sent: Tuesday, October 01, 2002 11:24
AM
Subject: Re: What is this
JComponent?
in that case what coulf be the solution
Greg Munt
wrote:
That's the AWT way of doing things. Overriding paint
would likely cause problems if a PLAF were required later
on.
-----
Original Message -----
Sent:
Tuesday, October 01, 2002 10:35 AM
Subject:
Re: What is this JComponent?
for this you would have to create your custom button
extending from JButton and then overriding its paint method
Xiao Wei wrote:
Hi Vikram,
Thank you very much for your quick
response.
Yes, you are right we can have a button
which has icon at top and text at bottom. But how can I implement that when I first click on
it, the background color of the text is changed(only getting
focus, not fire an event) and click again, then fire one
event?
Thanks.
Yeah .. They are
simple JButtons.. whose icon can be set for normal , mouseOver and
mousePressed mode.
Regards
Vikram
Xiao
Wei wrote:
Hi all,
I have seen many Swing applications
that have such components which have icon at the top and text at
the bottom. When you first click on them, background color of
the text is changed (getting focus), and click on them again,
fire one event listener.
Does anyone know this?
Thanks.
<<Xiao
Wei.vcf>>
--
Regards
Vikram Kumar
http://www.employees.org/~vikram
Accept what you cannot change and change what you cannot accept.
--
Regards
Vikram Kumar
http://www.employees.org/~vikram
Accept what you cannot change and change what you cannot accept.
|