> Hello ,
> i am trying to put a JComboBox into Header of a JTable, i do it by
[quoted text clipped - 3 lines]
> of it, it's seems that the combobox disabled.
> can somenone help me plz ?
Unfortunately, what you're trying to do is non-trivial to accomplish.
Using a custom renderer will not help you because a renderer by
definition is only something that is used to render (i.e paint) the
header cell - the component itself is NOT physically present in the
container hierarchy and hence cannot receive events which are required
for any user interaction.
The same issue also occurs if you want to insert custom components such
as say a JCombobox in the cell of a table. But the problem is easier to
solve in that case because Table cells can be made editable - and hence
defining your Custom component as a CellEditor will cause it to be
inserted at the cell location when the user clicks on the cell to begin
editing. But the Swing design of TableHeaders don't seem to allow a
Header to be editable, and so that approach doesn't work here.
The only option that I can see is to write your own version of a
JTableHeader - but I don't think it is by any means an easy solution to
implement.
BK
P.S. I haven't been active in Swing based development for about 2+
years now, and hence haven't kept track of changes in recent versions
of Swing - wonder if things have improved and there's an easier way out
?
Andrew Thompson - 28 Aug 2006 08:26 GMT
...
> P.S. I haven't been active in Swing based development for about 2+
> years now, ...
Why? Is it because you're now..
not in development?
Or using..
AWT?
Web-based interfaces?
Command line stuff?
..something not Java?
Andrew T.
Babu Kalakrishnan - 28 Aug 2006 08:56 GMT
> ...
> > P.S. I haven't been active in Swing based development for about 2+
[quoted text clipped - 7 lines]
> Command line stuff?
> ..something not Java?
Most of the work I do these days is in Web based applications
(Struts/Hibernate/JSP etc) . Very little in desktop apps.
BK
adil - 29 Aug 2006 20:26 GMT
Thanks guys,
Babu saids:
> The only option that I can see is to write your own version of a
> JTableHeader - but I don't think it is by any means an easy solution to
> implement.
you are right Babu and i found an interesting link where this problem is
solved , like you suggest
http://crionics.com/products/opensource/faq/swing_ex/JTableExamples9.html
my best regards
Babu Kalakrishnan - 30 Aug 2006 06:30 GMT
> Thanks guys,
> Babu saids:
[quoted text clipped - 6 lines]
> solved , like you suggest
> http://crionics.com/products/opensource/faq/swing_ex/JTableExamples9.html
That code has been floating around for several years - Lots excellent
examples in there, but beware that most of them (all ?) were written for
very early versions of Swing, and hence may not work "off the shelf"
with modern versions (Unless the maintainer of this site has taken some
pains to upgrade the code - The old URL used to be something else and
doesn't exist any more I think)
Regards,
BK